From d181afb606ba8caf4c6144fc718148e10be5dbaa Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 21 Jan 2020 12:44:09 -0300 Subject: [PATCH] Add theme switcher --- .gitignore | 2 + android/app/src/main/AndroidManifest.xml | 51 ++- android/app/src/main/res/values/strings.xml | 12 + android/gradle.properties | 3 +- ios/Podfile | 87 +++-- ios/Podfile.lock | 363 +++++++++++++----- ios/Runner.xcodeproj/project.pbxproj | 30 -- lib/login_state.dart | 78 ---- lib/main.dart | 79 ++-- lib/{ => others}/add_page_transition.dart | 0 .../category_selection_widget.dart | 0 lib/{ => others}/graph_widget.dart | 0 lib/{ => others}/month_widget.dart | 2 +- lib/pages/add_page.dart | 6 +- lib/pages/home_page.dart | 9 +- lib/pages/login_page.dart | 36 +- lib/pages/settings_page.dart | 52 +++ lib/states/login_state.dart | 138 +++++++ lib/states/theme_state.dart | 26 ++ pubspec.lock | 14 +- pubspec.yaml | 4 +- 21 files changed, 697 insertions(+), 295 deletions(-) create mode 100644 android/app/src/main/res/values/strings.xml delete mode 100644 lib/login_state.dart rename lib/{ => others}/add_page_transition.dart (100%) rename lib/{ => others}/category_selection_widget.dart (100%) rename lib/{ => others}/graph_widget.dart (100%) rename lib/{ => others}/month_widget.dart (98%) create mode 100644 lib/pages/settings_page.dart create mode 100644 lib/states/login_state.dart create mode 100644 lib/states/theme_state.dart diff --git a/.gitignore b/.gitignore index 54adec2..a7318c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.flutter-plugins-dependencies +ios/Flutter/flutter_export_environment.sh # Miscellaneous *.class *.log diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ef9e979..926e3b0 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -7,16 +7,39 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + + + android:icon="@mipmap/ic_launcher" + android:label="como_gasto"> + + + + + + + + + + + + + + + 605813330179453 + + + fb605813330179453 + \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index 678cd62..d2032bc 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx1536M android.enableJetifier=true -android.useAndroidX=true \ No newline at end of file +android.useAndroidX=true +android.enableR8=true diff --git a/ios/Podfile b/ios/Podfile index 64eddc6..b30a428 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -15,53 +15,72 @@ def parse_KV_file(file, separator='=') if !File.exists? file_abs_path return []; end - pods_ary = [] + generated_key_values = {} 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 + File.foreach(file_abs_path) do |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) + generated_key_values[podname] = podpath + else + puts "Invalid plugin specification: #{line}" + end + end + generated_key_values end target 'Runner' do use_frameworks! + use_modular_headers! + + # Flutter Pod + + copied_flutter_dir = File.join(__dir__, 'Flutter') + copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') + copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') + unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) + # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. + # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. + # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. + + generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') + unless File.exist?(generated_xcode_build_settings_path) + raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) + cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; + + unless File.exist?(copied_framework_path) + FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) + end + unless File.exist?(copied_podspec_path) + FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) + end + end + + # Keep pod path relative so it can be checked into Podfile.lock. + pod 'Flutter', :path => 'Flutter' + + # Plugin Pods # 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') - } + plugin_pods.each do |name, path| + symlink = File.join('.symlinks', 'plugins', name) + File.symlink(path, symlink) + pod name, :path => File.join(symlink, 'ios') + end end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 049a702..56c94fb 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,4 +1,163 @@ PODS: + - abseil/algorithm (0.20190808): + - abseil/algorithm/algorithm (= 0.20190808) + - abseil/algorithm/container (= 0.20190808) + - abseil/algorithm/algorithm (0.20190808) + - abseil/algorithm/container (0.20190808): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/base (0.20190808): + - abseil/base/atomic_hook (= 0.20190808) + - abseil/base/base (= 0.20190808) + - abseil/base/base_internal (= 0.20190808) + - abseil/base/bits (= 0.20190808) + - abseil/base/config (= 0.20190808) + - abseil/base/core_headers (= 0.20190808) + - abseil/base/dynamic_annotations (= 0.20190808) + - abseil/base/endian (= 0.20190808) + - abseil/base/log_severity (= 0.20190808) + - abseil/base/malloc_internal (= 0.20190808) + - abseil/base/pretty_function (= 0.20190808) + - abseil/base/spinlock_wait (= 0.20190808) + - abseil/base/throw_delegate (= 0.20190808) + - abseil/base/atomic_hook (0.20190808) + - abseil/base/base (0.20190808): + - abseil/base/atomic_hook + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/log_severity + - abseil/base/spinlock_wait + - abseil/meta/type_traits + - abseil/base/base_internal (0.20190808): + - abseil/meta/type_traits + - abseil/base/bits (0.20190808): + - abseil/base/core_headers + - abseil/base/config (0.20190808) + - abseil/base/core_headers (0.20190808): + - abseil/base/config + - abseil/base/dynamic_annotations (0.20190808) + - abseil/base/endian (0.20190808): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/log_severity (0.20190808): + - abseil/base/core_headers + - abseil/base/malloc_internal (0.20190808): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/spinlock_wait + - abseil/base/pretty_function (0.20190808) + - abseil/base/spinlock_wait (0.20190808): + - abseil/base/core_headers + - abseil/base/throw_delegate (0.20190808): + - abseil/base/base + - abseil/base/config + - abseil/memory (0.20190808): + - abseil/memory/memory (= 0.20190808) + - abseil/memory/memory (0.20190808): + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/meta (0.20190808): + - abseil/meta/type_traits (= 0.20190808) + - abseil/meta/type_traits (0.20190808): + - abseil/base/config + - abseil/numeric/int128 (0.20190808): + - abseil/base/config + - abseil/base/core_headers + - abseil/strings/internal (0.20190808): + - abseil/base/core_headers + - abseil/base/endian + - abseil/meta/type_traits + - abseil/strings/strings (0.20190808): + - abseil/base/base + - abseil/base/bits + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/throw_delegate + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/strings/internal + - abseil/time (0.20190808): + - abseil/time/internal (= 0.20190808) + - abseil/time/time (= 0.20190808) + - abseil/time/internal (0.20190808): + - abseil/time/internal/cctz (= 0.20190808) + - abseil/time/internal/cctz (0.20190808): + - abseil/time/internal/cctz/civil_time (= 0.20190808) + - abseil/time/internal/cctz/includes (= 0.20190808) + - abseil/time/internal/cctz/time_zone (= 0.20190808) + - abseil/time/internal/cctz/civil_time (0.20190808) + - abseil/time/internal/cctz/includes (0.20190808) + - abseil/time/internal/cctz/time_zone (0.20190808): + - abseil/time/internal/cctz/civil_time + - abseil/time/time (0.20190808): + - abseil/base/base + - abseil/base/core_headers + - abseil/numeric/int128 + - abseil/strings/strings + - abseil/time/internal/cctz/civil_time + - abseil/time/internal/cctz/time_zone + - abseil/types (0.20190808): + - abseil/types/any (= 0.20190808) + - abseil/types/bad_any_cast (= 0.20190808) + - abseil/types/bad_any_cast_impl (= 0.20190808) + - abseil/types/bad_optional_access (= 0.20190808) + - abseil/types/bad_variant_access (= 0.20190808) + - abseil/types/compare (= 0.20190808) + - abseil/types/optional (= 0.20190808) + - abseil/types/span (= 0.20190808) + - abseil/types/variant (= 0.20190808) + - abseil/types/any (0.20190808): + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/bad_any_cast + - abseil/utility/utility + - abseil/types/bad_any_cast (0.20190808): + - abseil/base/config + - abseil/types/bad_any_cast_impl + - abseil/types/bad_any_cast_impl (0.20190808): + - abseil/base/base + - abseil/base/config + - abseil/types/bad_optional_access (0.20190808): + - abseil/base/base + - abseil/base/config + - abseil/types/bad_variant_access (0.20190808): + - abseil/base/base + - abseil/base/config + - abseil/types/compare (0.20190808): + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/optional (0.20190808): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/types/bad_optional_access + - abseil/utility/utility + - abseil/types/span (0.20190808): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/base/throw_delegate + - abseil/meta/type_traits + - abseil/types/variant (0.20190808): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/bad_variant_access + - abseil/utility/utility + - abseil/utility/utility (0.20190808): + - abseil/base/base_internal + - abseil/base/config + - abseil/meta/type_traits - BoringSSL-GRPC (0.0.3): - BoringSSL-GRPC/Implementation (= 0.0.3) - BoringSSL-GRPC/Interface (= 0.0.3) @@ -9,20 +168,20 @@ PODS: - Firebase/Core - Firebase/Firestore (~> 6.0) - Flutter - - Firebase/Auth (6.0.0): + - Firebase/Auth (6.14.0): - Firebase/CoreOnly - - FirebaseAuth (~> 6.0.0) - - Firebase/Core (6.0.0): + - FirebaseAuth (~> 6.4.1) + - Firebase/Core (6.14.0): - Firebase/CoreOnly - - FirebaseAnalytics (= 6.0.0) - - Firebase/CoreOnly (6.0.0): - - FirebaseCore (= 6.0.0) - - Firebase/Firestore (6.0.0): + - FirebaseAnalytics (= 6.1.7) + - Firebase/CoreOnly (6.14.0): + - FirebaseCore (= 6.5.0) + - Firebase/Firestore (6.14.0): - Firebase/CoreOnly - - FirebaseFirestore (~> 1.3.0) - - Firebase/Storage (6.0.0): + - FirebaseFirestore (~> 1.8.2) + - Firebase/Storage (6.14.0): - Firebase/CoreOnly - - FirebaseStorage (~> 3.2.0) + - FirebaseStorage (~> 3.4.3) - firebase_auth (0.0.1): - Firebase/Auth (~> 6.0) - Firebase/Core @@ -33,45 +192,52 @@ PODS: - firebase_storage (0.0.1): - Firebase/Storage - Flutter - - FirebaseAnalytics (6.0.0): - - FirebaseCore (~> 6.0) - - FirebaseInstanceID (~> 4.0) - - GoogleAppMeasurement (= 6.0.0) + - FirebaseAnalytics (6.1.7): + - FirebaseCore (~> 6.5) + - FirebaseInstanceID (~> 4.2) + - GoogleAppMeasurement (= 6.1.7) - GoogleUtilities/AppDelegateSwizzler (~> 6.0) - GoogleUtilities/MethodSwizzler (~> 6.0) - GoogleUtilities/Network (~> 6.0) - "GoogleUtilities/NSData+zlib (~> 6.0)" - - nanopb (~> 0.3) - - FirebaseAuth (6.0.0): + - nanopb (= 0.3.9011) + - FirebaseAuth (6.4.1): - FirebaseAuthInterop (~> 1.0) - - FirebaseCore (~> 6.0) - - GoogleUtilities/AppDelegateSwizzler (~> 6.0) - - GoogleUtilities/Environment (~> 6.0) + - FirebaseCore (~> 6.2) + - GoogleUtilities/AppDelegateSwizzler (~> 6.2) + - GoogleUtilities/Environment (~> 6.2) - GTMSessionFetcher/Core (~> 1.1) - FirebaseAuthInterop (1.0.0) - - FirebaseCore (6.0.0): - - GoogleUtilities/Environment (~> 6.0) - - GoogleUtilities/Logger (~> 6.0) - - FirebaseFirestore (1.3.0): - - FirebaseAuthInterop (~> 1.0) - - FirebaseCore (~> 6.0) - - FirebaseFirestore/abseil-cpp (= 1.3.0) - - "gRPC-C++ (= 0.0.8)" - - leveldb-library (~> 1.20) + - FirebaseCore (6.5.0): + - FirebaseCoreDiagnostics (~> 1.0) + - FirebaseCoreDiagnosticsInterop (~> 1.0) + - GoogleUtilities/Environment (~> 6.4) + - GoogleUtilities/Logger (~> 6.4) + - FirebaseCoreDiagnostics (1.1.2): + - FirebaseCoreDiagnosticsInterop (~> 1.0) + - GoogleDataTransportCCTSupport (~> 1.0) + - GoogleUtilities/Environment (~> 6.2) + - GoogleUtilities/Logger (~> 6.2) - nanopb (~> 0.3.901) - - Protobuf (~> 3.1) - - FirebaseFirestore/abseil-cpp (1.3.0): + - FirebaseCoreDiagnosticsInterop (1.1.0) + - FirebaseFirestore (1.8.3): + - abseil/algorithm (= 0.20190808) + - abseil/base (= 0.20190808) + - abseil/memory (= 0.20190808) + - abseil/meta (= 0.20190808) + - abseil/strings/strings (= 0.20190808) + - abseil/time (= 0.20190808) + - abseil/types (= 0.20190808) - FirebaseAuthInterop (~> 1.0) - - FirebaseCore (~> 6.0) - - "gRPC-C++ (= 0.0.8)" - - leveldb-library (~> 1.20) + - FirebaseCore (~> 6.2) + - "gRPC-C++ (= 0.0.9)" + - leveldb-library (~> 1.22) - nanopb (~> 0.3.901) - - Protobuf (~> 3.1) - - FirebaseInstanceID (4.0.0): - - FirebaseCore (~> 6.0) - - GoogleUtilities/Environment (~> 6.0) - - GoogleUtilities/UserDefaults (~> 6.0) - - FirebaseStorage (3.2.1): + - FirebaseInstanceID (4.2.8): + - FirebaseCore (~> 6.5) + - GoogleUtilities/Environment (~> 6.4) + - GoogleUtilities/UserDefaults (~> 6.4) + - FirebaseStorage (3.4.3): - FirebaseAuthInterop (~> 1.0) - FirebaseCore (~> 6.0) - GTMSessionFetcher/Core (~> 1.1) @@ -81,12 +247,16 @@ PODS: - google_sign_in (0.0.1): - Flutter - GoogleSignIn (~> 4.0) - - GoogleAppMeasurement (6.0.0): + - GoogleAppMeasurement (6.1.7): - GoogleUtilities/AppDelegateSwizzler (~> 6.0) - GoogleUtilities/MethodSwizzler (~> 6.0) - GoogleUtilities/Network (~> 6.0) - "GoogleUtilities/NSData+zlib (~> 6.0)" - - nanopb (~> 0.3) + - nanopb (= 0.3.9011) + - GoogleDataTransport (3.2.0) + - GoogleDataTransportCCTSupport (1.2.3): + - GoogleDataTransport (~> 3.2) + - nanopb (~> 0.3.901) - GoogleSignIn (4.4.0): - "GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)" - "GoogleToolboxForMac/NSString+URLArguments (~> 2.1)" @@ -99,50 +269,51 @@ PODS: - GoogleToolboxForMac/Defines (= 2.2.1) - "GoogleToolboxForMac/NSString+URLArguments (= 2.2.1)" - "GoogleToolboxForMac/NSString+URLArguments (2.2.1)" - - GoogleUtilities/AppDelegateSwizzler (6.1.0): + - GoogleUtilities/AppDelegateSwizzler (6.4.0): - GoogleUtilities/Environment - GoogleUtilities/Logger - GoogleUtilities/Network - - GoogleUtilities/Environment (6.1.0) - - GoogleUtilities/Logger (6.1.0): + - GoogleUtilities/Environment (6.4.0) + - GoogleUtilities/Logger (6.4.0): - GoogleUtilities/Environment - - GoogleUtilities/MethodSwizzler (6.1.0): + - GoogleUtilities/MethodSwizzler (6.4.0): - GoogleUtilities/Logger - - GoogleUtilities/Network (6.1.0): + - GoogleUtilities/Network (6.4.0): - GoogleUtilities/Logger - "GoogleUtilities/NSData+zlib" - GoogleUtilities/Reachability - - "GoogleUtilities/NSData+zlib (6.1.0)" - - GoogleUtilities/Reachability (6.1.0): + - "GoogleUtilities/NSData+zlib (6.4.0)" + - GoogleUtilities/Reachability (6.4.0): - GoogleUtilities/Logger - - GoogleUtilities/UserDefaults (6.1.0): + - GoogleUtilities/UserDefaults (6.4.0): - GoogleUtilities/Logger - - "gRPC-C++ (0.0.8)": - - "gRPC-C++/Implementation (= 0.0.8)" - - "gRPC-C++/Interface (= 0.0.8)" - - "gRPC-C++/Implementation (0.0.8)": - - "gRPC-C++/Interface (= 0.0.8)" - - gRPC-Core (= 1.19.0) + - "gRPC-C++ (0.0.9)": + - "gRPC-C++/Implementation (= 0.0.9)" + - "gRPC-C++/Interface (= 0.0.9)" + - "gRPC-C++/Implementation (0.0.9)": + - "gRPC-C++/Interface (= 0.0.9)" + - gRPC-Core (= 1.21.0) - nanopb (~> 0.3) - - "gRPC-C++/Interface (0.0.8)" - - gRPC-Core (1.19.0): - - gRPC-Core/Implementation (= 1.19.0) - - gRPC-Core/Interface (= 1.19.0) - - gRPC-Core/Implementation (1.19.0): + - "gRPC-C++/Interface (0.0.9)" + - gRPC-Core (1.21.0): + - gRPC-Core/Implementation (= 1.21.0) + - gRPC-Core/Interface (= 1.21.0) + - gRPC-Core/Implementation (1.21.0): - BoringSSL-GRPC (= 0.0.3) - - gRPC-Core/Interface (= 1.19.0) + - gRPC-Core/Interface (= 1.21.0) - nanopb (~> 0.3) - - gRPC-Core/Interface (1.19.0) - - GTMSessionFetcher/Core (1.2.2) + - gRPC-Core/Interface (1.21.0) + - GTMSessionFetcher/Core (1.3.1) - image_picker (0.0.1): - Flutter - - 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) + - leveldb-library (1.22) + - local_auth (0.0.1): + - Flutter + - nanopb (0.3.9011): + - nanopb/decode (= 0.3.9011) + - nanopb/encode (= 0.3.9011) + - nanopb/decode (0.3.9011) + - nanopb/encode (0.3.9011) - shared_preferences (0.0.1): - Flutter @@ -151,24 +322,30 @@ DEPENDENCIES: - firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) - firebase_core (from `.symlinks/plugins/firebase_core/ios`) - firebase_storage (from `.symlinks/plugins/firebase_storage/ios`) - - Flutter (from `.symlinks/flutter/ios`) + - Flutter (from `Flutter`) - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) - google_sign_in (from `.symlinks/plugins/google_sign_in/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`) + - local_auth (from `.symlinks/plugins/local_auth/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) SPEC REPOS: https://github.com/cocoapods/specs.git: + - abseil - BoringSSL-GRPC - Firebase - FirebaseAnalytics - FirebaseAuth - FirebaseAuthInterop - FirebaseCore + - FirebaseCoreDiagnostics + - FirebaseCoreDiagnosticsInterop - FirebaseFirestore - FirebaseInstanceID - FirebaseStorage - GoogleAppMeasurement + - GoogleDataTransport + - GoogleDataTransportCCTSupport - GoogleSignIn - GoogleToolboxForMac - GoogleUtilities @@ -177,7 +354,6 @@ SPEC REPOS: - GTMSessionFetcher - leveldb-library - nanopb - - Protobuf EXTERNAL SOURCES: cloud_firestore: @@ -189,46 +365,53 @@ EXTERNAL SOURCES: firebase_storage: :path: ".symlinks/plugins/firebase_storage/ios" Flutter: - :path: ".symlinks/flutter/ios" + :path: Flutter flutter_local_notifications: :path: ".symlinks/plugins/flutter_local_notifications/ios" google_sign_in: :path: ".symlinks/plugins/google_sign_in/ios" image_picker: :path: ".symlinks/plugins/image_picker/ios" + local_auth: + :path: ".symlinks/plugins/local_auth/ios" shared_preferences: :path: ".symlinks/plugins/shared_preferences/ios" SPEC CHECKSUMS: + abseil: 18063d773f5366ff8736a050fe035a28f635fd27 BoringSSL-GRPC: db8764df3204ccea016e1c8dd15d9a9ad63ff318 - cloud_firestore: c6f34148c1dfbb57a6147f9bb49c1c9f5c27036e - Firebase: fa80b9d987ca014a1ba9357496ef2a0178b28b12 + cloud_firestore: c5d1e4d114eecb1dfb535f008435685bcf6063f1 + Firebase: 0219bb4782eb1406f1b9b0628a2e625484ce910d firebase_auth: 7a2cc520766f90212b845a5b35316601707bfa25 firebase_core: ce5006bb48508ee4e71e0f429a3f519bb8ee2961 firebase_storage: d83bfc0e0e849b2f871a34c474466bf5014ff304 - FirebaseAnalytics: 1743c5f4de3687d0745709dfdc4b1dea1484f44c - FirebaseAuth: efc72b0f6fe075d2a6de8d81a6d9de83ef2b47eb + FirebaseAnalytics: f68b9f3f1241385129ae0a83b63627fc420c05e5 + FirebaseAuth: 831577b184ecaba38bc886768c1c22a450cc44e3 FirebaseAuthInterop: 0ffa57668be100582bb7643d4fcb7615496c41fc - FirebaseCore: e38f025287b413255a53acc1945d048a112047f7 - FirebaseFirestore: 0537b2a960a4819fae2834e688e5daeb571c81d6 - FirebaseInstanceID: 0e0348a3c00a734fa376a070f5ad4533ad975cb5 - FirebaseStorage: 926d41552072b9fee67aa645760f05f87b7ce604 + FirebaseCore: 632e05cc5e1199d9147122c16d92305eb04c34bd + FirebaseCoreDiagnostics: 511f4f3ed7d440bb69127e8b97c2bc8befae639e + FirebaseCoreDiagnosticsInterop: e9b1b023157e3a2fc6418b5cb601e79b9af7b3a0 + FirebaseFirestore: 52120e2833f804a874ba1a9f59aab864a8ae2286 + FirebaseInstanceID: ce993a3c3670a8f5d47ce371ac5d143c560608c5 + FirebaseStorage: 93fe2f8190a01bfb2b2c4932df7d679744c4ef1d Flutter: 0e3d915762c693b495b44d77113d4970485de6ec flutter_local_notifications: 9e4738ce2471c5af910d961a6b7eadcf57c50186 google_sign_in: 27e70a98b529f0b076d4b19f231b81da28b1750b - GoogleAppMeasurement: 7f028ea162b72c8f326daec74afc95d94f7a47d6 + GoogleAppMeasurement: db118eb61a97dd8c4f7014e368d3c335cbbcf80a + GoogleDataTransport: 8e9b210c97d55fbff306cc5468ff91b9cb32dcf5 + GoogleDataTransportCCTSupport: 202d7cdf9c4a7d81a2bb7f7e7e1ba6faa421b1f2 GoogleSignIn: 7ff245e1a7b26d379099d3243a562f5747e23d39 GoogleToolboxForMac: b3553629623a3b1bff17f555e736cd5a6d95ad55 - GoogleUtilities: 84df567c76ca84f67b7bb40e769fdd4acc746a10 - "gRPC-C++": 98be881723177d8c4faf5fdffacb582c7b4971a2 - gRPC-Core: bd9472c8daa2e414b9f8038ba667bf56ce0e02b8 - GTMSessionFetcher: 61bb0f61a4cb560030f1222021178008a5727a23 + GoogleUtilities: 29bd0d8f850efbd28cff6d99e8b7da1f8d236bcf + "gRPC-C++": 9dfe7b44821e7b3e44aacad2af29d2c21f7cde83 + gRPC-Core: c9aef9a261a1247e881b18059b84d597293c9947 + GTMSessionFetcher: cea130bbfe5a7edc8d06d3f0d17288c32ffe9925 image_picker: e3eacd46b94694dde7cf2705955cece853aa1a8f - leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5 - nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48 - Protobuf: 7a877b7f3e5964e3fce995e2eb323dbc6831bb5a + leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7 + local_auth: 2571c49920ae469f46d5557435fad8fa473a5e88 + nanopb: 18003b5e52dab79db540fe93fe9579f399bd1ccd shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 -PODFILE CHECKSUM: ebd43b443038e611b86ede96e613bd6033c49497 +PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83 COCOAPODS: 1.6.1 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 39ad505..6b40475 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -249,36 +249,9 @@ files = ( ); inputPaths = ( - "${PODS_ROOT}/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}/GoogleToolboxForMac/GoogleToolboxForMac.framework", - "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.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-Core/grpc.framework", - "${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework", - "${BUILT_PRODUCTS_DIR}/leveldb-library/leveldb.framework", - "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework", - "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.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}/GoogleToolboxForMac.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.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}/grpc.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -293,14 +266,11 @@ inputFileListPaths = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh", - "${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle", ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( ); outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/lib/login_state.dart b/lib/login_state.dart deleted file mode 100644 index 48f2e09..0000000 --- a/lib/login_state.dart +++ /dev/null @@ -1,78 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:firebase_auth/firebase_auth.dart'; -import 'package:google_sign_in/google_sign_in.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -class LoginState with ChangeNotifier { - final GoogleSignIn _googleSignIn = GoogleSignIn(); - final FirebaseAuth _auth = FirebaseAuth.instance; - SharedPreferences _prefs; - - bool _loggedIn = false; - bool _loading = true; - FirebaseUser _user; - - LoginState() { - loginState(); - } - - bool isLoggedIn() => _loggedIn; - - bool isLoading() => _loading; - - FirebaseUser currentUser() => _user; - - void login() async { - _loading = true; - notifyListeners(); - - _user = await _handleSignIn(); - - _loading = false; - if (_user != null) { - _prefs.setBool('isLoggedIn', true); - _loggedIn = true; - notifyListeners(); - } else { - _loggedIn = false; - notifyListeners(); - } - } - - void logout() { - _prefs.clear(); - _googleSignIn.signOut(); - _loggedIn = false; - notifyListeners(); - } - - Future _handleSignIn() async { - final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); - if (googleUser == null) { - return null; - } - final GoogleSignInAuthentication googleAuth = await googleUser.authentication; - - final AuthCredential credential = GoogleAuthProvider.getCredential( - accessToken: googleAuth.accessToken, - idToken: googleAuth.idToken, - ); - - final FirebaseUser user = await _auth.signInWithCredential(credential); - print("signed in " + user.displayName); - return user; - } - - void loginState() async { - _prefs = await SharedPreferences.getInstance(); - if (_prefs.containsKey('isLoggedIn')) { - _user = await _auth.currentUser(); - _loggedIn = _user != null; - _loading = false; - notifyListeners(); - } else { - _loading = false; - notifyListeners(); - } - } -} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 0769fad..9e168dd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ -import 'package:como_gasto/add_page_transition.dart'; -import 'package:como_gasto/login_state.dart'; +import 'package:como_gasto/others/add_page_transition.dart'; +import 'package:como_gasto/pages/settings_page.dart'; +import 'package:como_gasto/states/login_state.dart'; import 'package:como_gasto/pages/add_page.dart'; import 'package:como_gasto/pages/details_page_container.dart'; import 'package:como_gasto/pages/home_page.dart'; @@ -8,6 +9,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'expenses_repository.dart'; +import 'states/theme_state.dart'; void main() => runApp(MyApp()); @@ -16,6 +18,9 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MultiProvider( providers: [ + ChangeNotifierProvider( + builder: (_) => ThemeState(), + ), ChangeNotifierProvider( builder: (BuildContext context) => LoginState(), ), @@ -30,39 +35,45 @@ class MyApp extends StatelessWidget { }, ) ], - child: MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - primarySwatch: Colors.blue, - ), - onGenerateRoute: (settings) { - if (settings.name == '/details') { - DetailsParams params = settings.arguments; - return MaterialPageRoute(builder: (BuildContext context) { - return DetailsPageContainer( - params: params, - ); - }); - } else if (settings.name == '/add') { - Rect buttonRect = settings.arguments; + child: Consumer( + builder: (context, state, child) { + return MaterialApp( + title: 'Flutter Demo', + theme: state.currentTheme, + onGenerateRoute: (settings) { + if (settings.name == '/details') { + DetailsParams params = settings.arguments; + return MaterialPageRoute(builder: (BuildContext context) { + return DetailsPageContainer( + params: params, + ); + }); + } else if (settings.name == '/add') { + Rect buttonRect = settings.arguments; - return AddPageTransition( - page: AddPage( - buttonRect: buttonRect, - ), - ); - } - return null; - }, - routes: { - '/': (BuildContext context) { - var state = Provider.of(context); - if (state.isLoggedIn()) { - return HomePage(); - } else { - return LoginPage(); - } - }, + return AddPageTransition( + page: AddPage( + buttonRect: buttonRect, + ), + ); + } else if (settings.name == '/settings') { + return MaterialPageRoute(builder: (BuildContext context) { + return SettingsPage(); + }); + } + return null; + }, + routes: { + '/': (BuildContext context) { + var state = Provider.of(context); + if (state.isLoggedIn()) { + return HomePage(); + } else { + return LoginPage(); + } + }, + }, + ); }, ), ); diff --git a/lib/add_page_transition.dart b/lib/others/add_page_transition.dart similarity index 100% rename from lib/add_page_transition.dart rename to lib/others/add_page_transition.dart diff --git a/lib/category_selection_widget.dart b/lib/others/category_selection_widget.dart similarity index 100% rename from lib/category_selection_widget.dart rename to lib/others/category_selection_widget.dart diff --git a/lib/graph_widget.dart b/lib/others/graph_widget.dart similarity index 100% rename from lib/graph_widget.dart rename to lib/others/graph_widget.dart diff --git a/lib/month_widget.dart b/lib/others/month_widget.dart similarity index 98% rename from lib/month_widget.dart rename to lib/others/month_widget.dart index f1e3c47..f49631a 100644 --- a/lib/month_widget.dart +++ b/lib/others/month_widget.dart @@ -1,5 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:como_gasto/graph_widget.dart'; +import 'package:como_gasto/others/graph_widget.dart'; import 'package:como_gasto/pages/details_page_container.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/pages/add_page.dart b/lib/pages/add_page.dart index 3722e50..23205ae 100644 --- a/lib/pages/add_page.dart +++ b/lib/pages/add_page.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:como_gasto/category_selection_widget.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'; @@ -292,7 +292,7 @@ class _AddPageState extends State with SingleTickerProviderStateMixin { decoration: BoxDecoration( borderRadius: BorderRadius.circular( buttonWidth * (1 - _buttonAnimation.value)), - color: Colors.blueAccent, + color: Theme.of(context).floatingActionButtonTheme.backgroundColor ?? Theme.of(context).primaryColor, ), child: MaterialButton( onPressed: () {}, @@ -314,7 +314,7 @@ class _AddPageState extends State with SingleTickerProviderStateMixin { right: 0, child: Builder(builder: (BuildContext context) { return Container( - decoration: BoxDecoration(color: Colors.blueAccent), + decoration: BoxDecoration(color: Theme.of(context).floatingActionButtonTheme.backgroundColor ?? Theme.of(context).primaryColor), child: MaterialButton( child: Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 0b3b532..1402393 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -1,5 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:como_gasto/month_widget.dart'; +import 'package:como_gasto/others/month_widget.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -7,7 +7,7 @@ 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 '../states/login_state.dart'; import '../utils.dart'; class HomePage extends StatefulWidget { @@ -73,8 +73,9 @@ class _HomePageState extends State { }), SizedBox(width: 48.0), _bottomAction(FontAwesomeIcons.wallet, () {}), - _bottomAction(FontAwesomeIcons.signOutAlt, () { - Provider.of(context).logout(); + _bottomAction(Icons.settings, () { + + Navigator.pushNamed(context, '/settings'); }), ], ), diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 5dd092f..66ed99d 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,9 +1,10 @@ import 'package:flare_flutter/flare_actor.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; -import '../login_state.dart'; +import '../states/login_state.dart'; class LoginPage extends StatefulWidget { @override @@ -54,11 +55,34 @@ class _LoginPageState extends State { return child; } }, - child: RaisedButton( - child: Text("Sign in with Google"), - onPressed: () { - Provider.of(context).login(); - }, + child: Container( + width: 200, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + FloatingActionButton( + backgroundColor: Color(0xff4285F4), + child: Icon(FontAwesomeIcons.google), + onPressed: () { + Provider.of(context).login(LoginProvider.GOOGLE); + }, + ), + FloatingActionButton( + backgroundColor: Color(0xff00aced), + child: Icon(FontAwesomeIcons.twitter), + onPressed: () { + Provider.of(context).login(LoginProvider.TWITTER); + }, + ), + FloatingActionButton( + backgroundColor: Color(0xff3b5998), + child: Icon(FontAwesomeIcons.facebook), + onPressed: () { + Provider.of(context).login(LoginProvider.FACEBOOK); + }, + ), + ], + ), ), ), Expanded( diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart new file mode 100644 index 0000000..63007dd --- /dev/null +++ b/lib/pages/settings_page.dart @@ -0,0 +1,52 @@ +import 'package:como_gasto/states/theme_state.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class SettingsPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Settings"), + ), + body: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Consumer( + builder: (context, state, child) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + child: Text("Use Dark mode?"), + ), + Switch( + value: state.isDarkModeEnabled, + onChanged: (_) { + state.setDarkMode(!state.isDarkModeEnabled); + }, + ), + ], + ); + }, + ), + Expanded( + child: Container(), + ), + Container( + width: double.infinity, + child: RaisedButton( + onPressed: () { + //Provider.of(context).logout(); + }, + child: Text("Sign Out"), + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/states/login_state.dart b/lib/states/login_state.dart new file mode 100644 index 0000000..7e77636 --- /dev/null +++ b/lib/states/login_state.dart @@ -0,0 +1,138 @@ +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +final String TWITTER_API = "..."; +final String TWITTER_SECRET = "..."; + +enum LoginProvider { + GOOGLE, + TWITTER, + FACEBOOK, +} + +class LoginState with ChangeNotifier { + final GoogleSignIn _googleSignIn = GoogleSignIn(); + final FirebaseAuth _auth = FirebaseAuth.instance; + SharedPreferences _prefs; + + // TODO: Set twitter credentials and uncomment logic + // Also uncomment the dependency on the pubspec.yaml file + // final TwitterLogin _twitterLogin = TwitterLogin( + // consumerKey: TWITTER_API, + // consumerSecret: TWITTER_SECRET, + // ); + + bool _loggedIn = false; + bool _loading = true; + FirebaseUser _user; + + LoginState() { + loginState(); + } + + bool isLoggedIn() => _loggedIn; + + bool isLoading() => _loading; + + FirebaseUser currentUser() => _user; + + void login(LoginProvider loginProvider) async { + _loading = true; + notifyListeners(); + + switch (loginProvider) { + case LoginProvider.GOOGLE: + _user = await _handleSignIn(); + break; + case LoginProvider.TWITTER: + _user = await _handleTwitterSignIn(); + break; + case LoginProvider.FACEBOOK: + _user = await _handleFacebookSignIn(); + break; + } + + _loading = false; + _loggedIn = _user != null; + _prefs.setBool('isLoggedIn', _loggedIn); + notifyListeners(); + } + + void logout() { + _prefs.clear(); + _googleSignIn.signOut(); + _loggedIn = false; + notifyListeners(); + } + + // TODO: Set twitter credentials and uncomment logic + // Also uncomment the dependency on the pubspec.yaml file + Future _handleFacebookSignIn() async { + // final facebookLogin = FacebookLogin(); + // final result = await facebookLogin.logIn(['email']); + // if (result.status != FacebookLoginStatus.loggedIn) { + // return null; + // } + // + // final AuthCredential credential = FacebookAuthProvider.getCredential( + // accessToken: result.accessToken.token, + // ); + // + // final FirebaseUser user = await _auth.signInWithCredential(credential); + // print("signed in " + user.displayName); + // return user; + return null; + } + + Future _handleTwitterSignIn() async { + // var twitterResult = await _twitterLogin.authorize(); + // if (twitterResult.status != TwitterLoginStatus.loggedIn) { + // return null; + // } + // + // var session = twitterResult.session; + // + // final AuthCredential credential = TwitterAuthProvider.getCredential( + // authToken: session.token, + // authTokenSecret: session.secret, + // ); + // + // final FirebaseUser user = await _auth.signInWithCredential(credential); + // print("signed in " + user.displayName); + // return user; + return null; + } + + Future _handleSignIn() async { + final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); + if (googleUser == null) { + return null; + } + final GoogleSignInAuthentication googleAuth = + await googleUser.authentication; + + final AuthCredential credential = GoogleAuthProvider.getCredential( + accessToken: googleAuth.accessToken, + idToken: googleAuth.idToken, + ); + + final FirebaseUser user = await _auth.signInWithCredential(credential); + print("signed in " + user.displayName); + return user; + } + + void loginState() async { + _prefs = await SharedPreferences.getInstance(); + if (_prefs.containsKey('isLoggedIn')) { + _user = await _auth.currentUser(); + _loggedIn = _user != null; + _loading = false; + notifyListeners(); + } else { + _loading = false; + notifyListeners(); + } + } +} diff --git a/lib/states/theme_state.dart b/lib/states/theme_state.dart new file mode 100644 index 0000000..8fd8a3c --- /dev/null +++ b/lib/states/theme_state.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; + +class ThemeState with ChangeNotifier { + bool _isDarkModeEnabled = false; + + ThemeData get currentTheme => _isDarkModeEnabled + ? ThemeData.dark().copyWith( + accentColor: Colors.red, + buttonTheme: ButtonThemeData( + buttonColor: Colors.red, + ), + floatingActionButtonTheme: FloatingActionButtonThemeData( + backgroundColor: Colors.red, + foregroundColor: Colors.white, + ), + toggleableActiveColor: Colors.red, + ) + : ThemeData.light(); + + bool get isDarkModeEnabled => _isDarkModeEnabled; + + void setDarkMode(bool b) { + _isDarkModeEnabled = b; + notifyListeners(); + } +} diff --git a/pubspec.lock b/pubspec.lock index ce416b9..a8f59e3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.10" + version: "2.0.11" args: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.4.0" boolean_selector: dependency: transitive description: @@ -56,7 +56,7 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "0.11.0+2" + version: "0.13.0+1" collection: dependency: transitive description: @@ -206,14 +206,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.1.8" path: dependency: transitive description: @@ -316,7 +316,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.11" typed_data: dependency: transitive description: @@ -354,4 +354,4 @@ packages: version: "2.1.16" sdks: dart: ">=2.4.0 <3.0.0" - flutter: ">=1.7.8+hotfix.3 <2.0.0" + flutter: ">=1.10.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index cc4e23a..ca98f82 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: sdk: flutter charts_flutter: ^0.6.0 font_awesome_flutter: ^8.4.0 - cloud_firestore: ^0.11.0+2 + cloud_firestore: ^0.13.0+1 firebase_storage: ^3.0.8 image_picker: ^0.6.1+11 uuid: @@ -32,6 +32,8 @@ dependencies: cupertino_icons: ^0.1.2 provider: ^3.0.0+1 google_sign_in: ^4.0.1+3 +# flutter_twitter_login: ^1.1.0 + #flutter_facebook_login: ^3.0.0 firebase_auth: ^0.11.1 shared_preferences: ^0.5.2 rect_getter: ^0.0.1