From 42407f2e4df14e6b87cc1850aa284c0d34cc5e48 Mon Sep 17 00:00:00 2001 From: Deepanshu Rohilla <52520071+Deepanshu-Rohilla@users.noreply.github.com> Date: Mon, 12 Apr 2021 13:42:29 +0530 Subject: [PATCH 1/9] Update pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5c73a02..5e0cf83 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: firebase_auth: ^0.14.0+5 cloud_firestore: ^0.13.5 firebase_core: ^0.4.2+1 - provider: ^3.1.0 + provider: ^4.3.3 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. flutter_spinkit: "^4.1.2" From c448f8ea1ea6d55a6c63e409c79c94be145f61ab Mon Sep 17 00:00:00 2001 From: Vishal Singh <31121102+tmibvishal@users.noreply.github.com> Date: Mon, 19 Jul 2021 00:51:53 +0530 Subject: [PATCH 2/9] Delete .vscode directory --- .vscode/launch.json | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 3287bb6..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Flutter", - "request": "launch", - "type": "dart" - } - ] -} \ No newline at end of file From 463e46c9729d794b3106155205452bf331566fd1 Mon Sep 17 00:00:00 2001 From: Vishal Singh <31121102+tmibvishal@users.noreply.github.com> Date: Mon, 19 Jul 2021 00:52:16 +0530 Subject: [PATCH 3/9] Update .gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b42e95d..efb7b97 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,7 @@ lib/generated_plugin_registrant.dart # Deploy Bot .gitsecret/keys/random_seed -!*.secret \ No newline at end of file +!*.secret + +# VS Code +.vscode From e2cb7a4e7875f3f677340ab39f1ebbd189ec363e Mon Sep 17 00:00:00 2001 From: as1605 <1605.aditya.singh@gmail.com> Date: Sun, 19 Dec 2021 16:06:21 +0530 Subject: [PATCH 4/9] Upgraded dependencies. Compiles successfully. need to fix firebase runtime errors --- android/app/build.gradle | 4 +- android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- functions/index.js | 2 +- ios/Flutter/AppFrameworkInfo.plist | 2 +- ios/Podfile | 81 +- ios/Podfile.lock | 714 ++++++++++-------- ios/Runner.xcodeproj/project.pbxproj | 65 +- .../contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- lib/main.dart | 90 ++- lib/screens/authenticate/change_email.dart | 27 +- lib/screens/authenticate/forgotpass.dart | 8 +- lib/screens/authenticate/register.dart | 26 +- lib/screens/authenticate/sign_in.dart | 14 +- .../authenticate/verified_email_check.dart | 55 +- .../chatscreen/chat_database/database.dart | 25 +- lib/screens/chatscreen/chat_screen.dart | 15 +- .../chatscreen/chat_widgets/chat_bubble.dart | 4 +- .../chatscreen/chat_widgets/chat_tile.dart | 4 +- .../chat_widgets/chat_users_list.dart | 22 +- .../chatscreen/chat_widgets/message.dart | 79 +- .../chatscreen/chat_widgets/new_message.dart | 20 +- lib/screens/createtrip.dart | 18 +- lib/screens/dashboard.dart | 36 +- lib/screens/edituserdetails.dart | 98 ++- lib/screens/filter.dart | 8 +- .../ended_group_details.dart | 119 ++- .../groupdetailscreen/groupdetails.dart | 397 +++++++--- lib/screens/groupscreen/editgroup.dart | 119 ++- lib/screens/groupscreen/group.dart | 545 +++++++++---- .../notifications/services/database.dart | 184 +++-- .../notifications/widgets/notifslist.dart | 45 +- .../notifications/widgets/notiftile.dart | 12 +- lib/screens/profile/userprofile.dart | 201 +++-- lib/screens/requests/myrequests.dart | 161 ++-- lib/screens/rootscreen.dart | 10 +- lib/screens/settings.dart | 119 ++- lib/screens/tripslist.dart | 205 +++-- lib/screens/wrapper.dart | 10 +- lib/services/auth.dart | 45 +- lib/services/database.dart | 201 +++-- lib/shared/loading.dart | 2 +- pubspec.lock | 114 +-- pubspec.yaml | 10 +- 45 files changed, 2589 insertions(+), 1335 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index da41d48..cfa651c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' } @@ -39,7 +39,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.devclub.shareacab" minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true diff --git a/android/build.gradle b/android/build.gradle index de57df6..70943ca 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.2' } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 296b146..bc6a58a 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/functions/index.js b/functions/index.js index e25fc5e..812a562 100644 --- a/functions/index.js +++ b/functions/index.js @@ -4,7 +4,7 @@ const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); -exports.myFunction = functions.firestore.document('chatroom/{chatroomid}/chats/{chatsId}').onCreate(async (snapshot, context) => { +exports.myFunction = functions.firestore.doc('chatroom/{chatroomid}/chats/{chatsId}').onCreate(async (snapshot, context) => { var docId; var tokens = []; var usersChat = []; diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..8c6e561 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 12.0 diff --git a/ios/Podfile b/ios/Podfile index b30a428..2c068c4 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -10,81 +10,32 @@ project 'Runner', { 'Release' => :release, } -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" end - generated_key_values = {} - skip_line_start_symbols = ["#", "/"] - 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 + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches end - generated_key_values + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" end +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + 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') - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.each do |name, path| - symlink = File.join('.symlinks', 'plugins', name) - File.symlink(path, symlink) - pod name, :path => File.join(symlink, 'ios') - end + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 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| - config.build_settings['ENABLE_BITCODE'] = 'NO' - end + flutter_additional_ios_build_settings(target) end end diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 57a4e57..6387e6d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,140 +1,320 @@ 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 (0.20200225.0): + - abseil/algorithm/algorithm (= 0.20200225.0) + - abseil/algorithm/container (= 0.20200225.0) + - abseil/algorithm/algorithm (0.20200225.0): + - abseil/base/config + - abseil/algorithm/container (0.20200225.0): - 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 (0.20200225.0): + - abseil/base/atomic_hook (= 0.20200225.0) + - abseil/base/base (= 0.20200225.0) + - abseil/base/base_internal (= 0.20200225.0) + - abseil/base/bits (= 0.20200225.0) + - abseil/base/config (= 0.20200225.0) + - abseil/base/core_headers (= 0.20200225.0) + - abseil/base/dynamic_annotations (= 0.20200225.0) + - abseil/base/endian (= 0.20200225.0) + - abseil/base/errno_saver (= 0.20200225.0) + - abseil/base/exponential_biased (= 0.20200225.0) + - abseil/base/log_severity (= 0.20200225.0) + - abseil/base/malloc_internal (= 0.20200225.0) + - abseil/base/periodic_sampler (= 0.20200225.0) + - abseil/base/pretty_function (= 0.20200225.0) + - abseil/base/raw_logging_internal (= 0.20200225.0) + - abseil/base/spinlock_wait (= 0.20200225.0) + - abseil/base/throw_delegate (= 0.20200225.0) + - abseil/base/atomic_hook (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/base (0.20200225.0): - 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/raw_logging_internal - abseil/base/spinlock_wait - abseil/meta/type_traits - - abseil/base/base_internal (0.20190808): + - abseil/base/base_internal (0.20200225.0): + - abseil/base/config - abseil/meta/type_traits - - abseil/base/bits (0.20190808): + - abseil/base/bits (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/config (0.20200225.0) + - abseil/base/core_headers (0.20200225.0): + - abseil/base/config + - abseil/base/dynamic_annotations (0.20200225.0) + - abseil/base/endian (0.20200225.0): + - abseil/base/config - abseil/base/core_headers - - abseil/base/config (0.20190808) - - abseil/base/core_headers (0.20190808): + - abseil/base/errno_saver (0.20200225.0): - abseil/base/config - - abseil/base/dynamic_annotations (0.20190808) - - abseil/base/endian (0.20190808): + - abseil/base/exponential_biased (0.20200225.0): - abseil/base/config - abseil/base/core_headers - - abseil/base/log_severity (0.20190808): + - abseil/base/log_severity (0.20200225.0): + - abseil/base/config - abseil/base/core_headers - - abseil/base/malloc_internal (0.20190808): + - abseil/base/malloc_internal (0.20200225.0): - abseil/base/base + - abseil/base/base_internal - 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/raw_logging_internal + - abseil/base/periodic_sampler (0.20200225.0): + - abseil/base/core_headers + - abseil/base/exponential_biased + - abseil/base/pretty_function (0.20200225.0) + - abseil/base/raw_logging_internal (0.20200225.0): + - abseil/base/atomic_hook + - abseil/base/config - abseil/base/core_headers - - abseil/base/throw_delegate (0.20190808): + - abseil/base/log_severity + - abseil/base/spinlock_wait (0.20200225.0): + - abseil/base/base_internal + - abseil/base/core_headers + - abseil/base/errno_saver + - abseil/base/throw_delegate (0.20200225.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/container/common (0.20200225.0): + - abseil/meta/type_traits + - abseil/types/optional + - abseil/container/compressed_tuple (0.20200225.0): + - abseil/utility/utility + - abseil/container/container_memory (0.20200225.0): + - abseil/memory/memory + - abseil/utility/utility + - abseil/container/fixed_array (0.20200225.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/throw_delegate + - abseil/container/compressed_tuple + - abseil/memory/memory + - abseil/container/flat_hash_map (0.20200225.0): + - abseil/algorithm/container + - abseil/container/container_memory + - abseil/container/hash_function_defaults + - abseil/container/raw_hash_map + - abseil/memory/memory + - abseil/container/hash_function_defaults (0.20200225.0): + - abseil/base/config + - abseil/hash/hash + - abseil/strings/strings + - abseil/container/hash_policy_traits (0.20200225.0): + - abseil/meta/type_traits + - abseil/container/hashtable_debug_hooks (0.20200225.0): + - abseil/base/config + - abseil/container/hashtablez_sampler (0.20200225.0): - abseil/base/base + - abseil/base/core_headers + - abseil/base/exponential_biased + - abseil/container/have_sse + - abseil/debugging/stacktrace + - abseil/memory/memory + - abseil/synchronization/synchronization + - abseil/utility/utility + - abseil/container/have_sse (0.20200225.0) + - abseil/container/inlined_vector (0.20200225.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/base/throw_delegate + - abseil/container/inlined_vector_internal + - abseil/memory/memory + - abseil/container/inlined_vector_internal (0.20200225.0): + - abseil/base/core_headers + - abseil/container/compressed_tuple + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/types/span + - abseil/container/layout (0.20200225.0): + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/strings/strings + - abseil/types/span + - abseil/utility/utility + - abseil/container/raw_hash_map (0.20200225.0): + - abseil/base/throw_delegate + - abseil/container/container_memory + - abseil/container/raw_hash_set + - abseil/container/raw_hash_set (0.20200225.0): + - abseil/base/bits - abseil/base/config - - abseil/memory (0.20190808): - - abseil/memory/memory (= 0.20190808) - - abseil/memory/memory (0.20190808): - abseil/base/core_headers + - abseil/base/endian + - abseil/container/common + - abseil/container/compressed_tuple + - abseil/container/container_memory + - abseil/container/hash_policy_traits + - abseil/container/hashtable_debug_hooks + - abseil/container/hashtablez_sampler + - abseil/container/have_sse + - abseil/container/layout + - abseil/memory/memory - abseil/meta/type_traits - - abseil/meta (0.20190808): - - abseil/meta/type_traits (= 0.20190808) - - abseil/meta/type_traits (0.20190808): + - abseil/utility/utility + - abseil/debugging/debugging_internal (0.20200225.0): - abseil/base/config - - abseil/numeric/int128 (0.20190808): + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/errno_saver + - abseil/base/raw_logging_internal + - abseil/debugging/demangle_internal (0.20200225.0): + - abseil/base/base - abseil/base/config - abseil/base/core_headers - - abseil/strings/internal (0.20190808): + - abseil/debugging/stacktrace (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/debugging/debugging_internal + - abseil/debugging/symbolize (0.20200225.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/malloc_internal + - abseil/base/raw_logging_internal + - abseil/debugging/debugging_internal + - abseil/debugging/demangle_internal + - abseil/hash/city (0.20200225.0): + - abseil/base/config - abseil/base/core_headers - abseil/base/endian + - abseil/hash/hash (0.20200225.0): + - abseil/base/core_headers + - abseil/base/endian + - abseil/container/fixed_array + - abseil/hash/city + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/strings/strings + - abseil/types/optional + - abseil/types/variant + - abseil/utility/utility + - abseil/memory (0.20200225.0): + - abseil/memory/memory (= 0.20200225.0) + - abseil/memory/memory (0.20200225.0): + - abseil/base/core_headers - abseil/meta/type_traits - - abseil/strings/strings (0.20190808): + - abseil/meta (0.20200225.0): + - abseil/meta/type_traits (= 0.20200225.0) + - abseil/meta/type_traits (0.20200225.0): + - abseil/base/config + - abseil/numeric/int128 (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/strings/internal (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/meta/type_traits + - abseil/strings/str_format (0.20200225.0): + - abseil/strings/str_format_internal + - abseil/strings/str_format_internal (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/strings/strings + - abseil/types/span + - abseil/strings/strings (0.20200225.0): - abseil/base/base - abseil/base/bits - abseil/base/config - abseil/base/core_headers - abseil/base/endian + - abseil/base/raw_logging_internal - 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/synchronization/graphcycles_internal (0.20200225.0): + - abseil/base/base + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/malloc_internal + - abseil/base/raw_logging_internal + - abseil/synchronization/kernel_timeout_internal (0.20200225.0): + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/time/time + - abseil/synchronization/synchronization (0.20200225.0): + - abseil/base/atomic_hook + - abseil/base/base + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/malloc_internal + - abseil/base/raw_logging_internal + - abseil/debugging/stacktrace + - abseil/debugging/symbolize + - abseil/synchronization/graphcycles_internal + - abseil/synchronization/kernel_timeout_internal + - abseil/time/time + - abseil/time (0.20200225.0): + - abseil/time/internal (= 0.20200225.0) + - abseil/time/time (= 0.20200225.0) + - abseil/time/internal (0.20200225.0): + - abseil/time/internal/cctz (= 0.20200225.0) + - abseil/time/internal/cctz (0.20200225.0): + - abseil/time/internal/cctz/civil_time (= 0.20200225.0) + - abseil/time/internal/cctz/time_zone (= 0.20200225.0) + - abseil/time/internal/cctz/civil_time (0.20200225.0): + - abseil/base/config + - abseil/time/internal/cctz/time_zone (0.20200225.0): + - abseil/base/config - abseil/time/internal/cctz/civil_time - - abseil/time/time (0.20190808): + - abseil/time/time (0.20200225.0): - abseil/base/base - abseil/base/core_headers + - abseil/base/raw_logging_internal - 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/types (0.20200225.0): + - abseil/types/any (= 0.20200225.0) + - abseil/types/bad_any_cast (= 0.20200225.0) + - abseil/types/bad_any_cast_impl (= 0.20200225.0) + - abseil/types/bad_optional_access (= 0.20200225.0) + - abseil/types/bad_variant_access (= 0.20200225.0) + - abseil/types/compare (= 0.20200225.0) + - abseil/types/optional (= 0.20200225.0) + - abseil/types/span (= 0.20200225.0) + - abseil/types/variant (= 0.20200225.0) + - abseil/types/any (0.20200225.0): - 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/types/bad_any_cast (0.20200225.0): - abseil/base/config - abseil/types/bad_any_cast_impl - - abseil/types/bad_any_cast_impl (0.20190808): - - abseil/base/base + - abseil/types/bad_any_cast_impl (0.20200225.0): - abseil/base/config - - abseil/types/bad_optional_access (0.20190808): - - abseil/base/base + - abseil/base/raw_logging_internal + - abseil/types/bad_optional_access (0.20200225.0): - abseil/base/config - - abseil/types/bad_variant_access (0.20190808): - - abseil/base/base + - abseil/base/raw_logging_internal + - abseil/types/bad_variant_access (0.20200225.0): - abseil/base/config - - abseil/types/compare (0.20190808): + - abseil/base/raw_logging_internal + - abseil/types/compare (0.20200225.0): - abseil/base/core_headers - abseil/meta/type_traits - - abseil/types/optional (0.20190808): + - abseil/types/optional (0.20200225.0): - abseil/base/base_internal - abseil/base/config - abseil/base/core_headers @@ -142,231 +322,175 @@ PODS: - abseil/meta/type_traits - abseil/types/bad_optional_access - abseil/utility/utility - - abseil/types/span (0.20190808): + - abseil/types/span (0.20200225.0): - abseil/algorithm/algorithm - abseil/base/core_headers - abseil/base/throw_delegate - abseil/meta/type_traits - - abseil/types/variant (0.20190808): + - abseil/types/variant (0.20200225.0): - 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/utility/utility (0.20200225.0): - 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) - - BoringSSL-GRPC/Implementation (0.0.3): - - BoringSSL-GRPC/Interface (= 0.0.3) - - BoringSSL-GRPC/Interface (0.0.3) - - cloud_firestore (0.0.1): - - Firebase/Core - - Firebase/Firestore (~> 6.0) + - BoringSSL-GRPC (0.0.7): + - BoringSSL-GRPC/Implementation (= 0.0.7) + - BoringSSL-GRPC/Interface (= 0.0.7) + - BoringSSL-GRPC/Implementation (0.0.7): + - BoringSSL-GRPC/Interface (= 0.0.7) + - BoringSSL-GRPC/Interface (0.0.7) + - cloud_firestore (3.1.5): + - Firebase/Firestore (= 8.9.0) + - firebase_core - Flutter - - cloud_firestore_web (0.1.0): - - Flutter - - Firebase/Auth (6.15.0): - - Firebase/CoreOnly - - FirebaseAuth (~> 6.4.2) - - Firebase/Core (6.15.0): + - Firebase/Auth (8.9.0): - Firebase/CoreOnly - - FirebaseAnalytics (= 6.2.1) - - Firebase/CoreOnly (6.15.0): - - FirebaseCore (= 6.6.0) - - Firebase/Firestore (6.15.0): + - FirebaseAuth (~> 8.9.0) + - Firebase/CoreOnly (8.9.0): + - FirebaseCore (= 8.9.0) + - Firebase/Firestore (8.9.0): - Firebase/CoreOnly - - FirebaseFirestore (~> 1.9.0) - - Firebase/Messaging (6.15.0): + - FirebaseFirestore (~> 8.9.0) + - Firebase/Messaging (8.9.0): - Firebase/CoreOnly - - FirebaseMessaging (~> 4.2.0) - - firebase_auth (0.0.1): - - Firebase/Auth (~> 6.0) - - Firebase/Core + - FirebaseMessaging (~> 8.9.0) + - firebase_auth (3.3.4): + - Firebase/Auth (= 8.9.0) + - firebase_core - Flutter - - firebase_core (0.0.1): - - Firebase/Core + - firebase_core (1.10.6): + - Firebase/CoreOnly (= 8.9.0) - Flutter - - firebase_core_web (0.1.0): + - firebase_messaging (11.2.4): + - Firebase/Messaging (= 8.9.0) + - firebase_core - Flutter - - firebase_messaging (0.0.1): - - Firebase/Core - - Firebase/Messaging - - Flutter - - FirebaseAnalytics (6.2.1): - - FirebaseCore (~> 6.6) - - FirebaseInstanceID (~> 4.3) - - GoogleAppMeasurement (= 6.2.1) - - GoogleUtilities/AppDelegateSwizzler (~> 6.0) - - GoogleUtilities/MethodSwizzler (~> 6.0) - - GoogleUtilities/Network (~> 6.0) - - "GoogleUtilities/NSData+zlib (~> 6.0)" - - nanopb (= 0.3.9011) - - FirebaseAnalyticsInterop (1.5.0) - - FirebaseAuth (6.4.2): - - FirebaseAuthInterop (~> 1.0) - - FirebaseCore (~> 6.2) - - GoogleUtilities/AppDelegateSwizzler (~> 6.2) - - GoogleUtilities/Environment (~> 6.2) - - GTMSessionFetcher/Core (~> 1.1) - - FirebaseAuthInterop (1.0.0) - - FirebaseCore (6.6.0): - - FirebaseCoreDiagnostics (~> 1.2) - - FirebaseCoreDiagnosticsInterop (~> 1.2) - - GoogleUtilities/Environment (~> 6.5) - - GoogleUtilities/Logger (~> 6.5) - - FirebaseCoreDiagnostics (1.2.0): - - FirebaseCoreDiagnosticsInterop (~> 1.2) - - GoogleDataTransportCCTSupport (~> 1.3) - - GoogleUtilities/Environment (~> 6.5) - - GoogleUtilities/Logger (~> 6.5) - - nanopb (~> 0.3.901) - - FirebaseCoreDiagnosticsInterop (1.2.0) - - FirebaseFirestore (1.9.0): - - 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.2) - - "gRPC-C++ (= 0.0.9)" + - FirebaseAuth (8.9.0): + - FirebaseCore (~> 8.0) + - GoogleUtilities/AppDelegateSwizzler (~> 7.6) + - GoogleUtilities/Environment (~> 7.6) + - GTMSessionFetcher/Core (~> 1.5) + - FirebaseCore (8.9.0): + - FirebaseCoreDiagnostics (~> 8.0) + - GoogleUtilities/Environment (~> 7.6) + - GoogleUtilities/Logger (~> 7.6) + - FirebaseCoreDiagnostics (8.10.0): + - GoogleDataTransport (~> 9.1) + - GoogleUtilities/Environment (~> 7.6) + - GoogleUtilities/Logger (~> 7.6) + - nanopb (~> 2.30908.0) + - FirebaseFirestore (8.9.1): + - abseil/algorithm (= 0.20200225.0) + - abseil/base (= 0.20200225.0) + - abseil/container/flat_hash_map (= 0.20200225.0) + - abseil/memory (= 0.20200225.0) + - abseil/meta (= 0.20200225.0) + - abseil/strings/strings (= 0.20200225.0) + - abseil/time (= 0.20200225.0) + - abseil/types (= 0.20200225.0) + - FirebaseCore (~> 8.0) + - "gRPC-C++ (~> 1.28.0)" - leveldb-library (~> 1.22) - - nanopb (~> 0.3.901) - - FirebaseInstallations (1.1.0): - - FirebaseCore (~> 6.6) - - GoogleUtilities/UserDefaults (~> 6.5) - - PromisesObjC (~> 1.2) - - FirebaseInstanceID (4.3.0): - - FirebaseCore (~> 6.6) - - FirebaseInstallations (~> 1.0) - - GoogleUtilities/Environment (~> 6.5) - - GoogleUtilities/UserDefaults (~> 6.5) - - FirebaseMessaging (4.2.1): - - FirebaseAnalyticsInterop (~> 1.5) - - FirebaseCore (~> 6.6) - - FirebaseInstanceID (~> 4.3) - - GoogleUtilities/AppDelegateSwizzler (~> 6.5) - - GoogleUtilities/Environment (~> 6.5) - - GoogleUtilities/Reachability (~> 6.5) - - GoogleUtilities/UserDefaults (~> 6.5) - - Protobuf (>= 3.9.2, ~> 3.9) + - nanopb (~> 2.30908.0) + - FirebaseInstallations (8.10.0): + - FirebaseCore (~> 8.0) + - GoogleUtilities/Environment (~> 7.6) + - GoogleUtilities/UserDefaults (~> 7.6) + - PromisesObjC (< 3.0, >= 1.2) + - FirebaseMessaging (8.9.0): + - FirebaseCore (~> 8.0) + - FirebaseInstallations (~> 8.0) + - GoogleDataTransport (~> 9.1) + - GoogleUtilities/AppDelegateSwizzler (~> 7.6) + - GoogleUtilities/Environment (~> 7.6) + - GoogleUtilities/Reachability (~> 7.6) + - GoogleUtilities/UserDefaults (~> 7.6) + - nanopb (~> 2.30908.0) - Flutter (1.0.0) - - GoogleAppMeasurement (6.2.1): - - GoogleUtilities/AppDelegateSwizzler (~> 6.0) - - GoogleUtilities/MethodSwizzler (~> 6.0) - - GoogleUtilities/Network (~> 6.0) - - "GoogleUtilities/NSData+zlib (~> 6.0)" - - nanopb (= 0.3.9011) - - GoogleDataTransport (3.3.0) - - GoogleDataTransportCCTSupport (1.3.0): - - GoogleDataTransport (~> 3.3) - - nanopb (~> 0.3.901) - - GoogleUtilities/AppDelegateSwizzler (6.5.0): + - GoogleDataTransport (9.1.2): + - GoogleUtilities/Environment (~> 7.2) + - nanopb (~> 2.30908.0) + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/AppDelegateSwizzler (7.6.0): - GoogleUtilities/Environment - GoogleUtilities/Logger - GoogleUtilities/Network - - GoogleUtilities/Environment (6.5.0) - - GoogleUtilities/Logger (6.5.0): + - GoogleUtilities/Environment (7.6.0): + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Logger (7.6.0): - GoogleUtilities/Environment - - GoogleUtilities/MethodSwizzler (6.5.0): - - GoogleUtilities/Logger - - GoogleUtilities/Network (6.5.0): + - GoogleUtilities/Network (7.6.0): - GoogleUtilities/Logger - "GoogleUtilities/NSData+zlib" - GoogleUtilities/Reachability - - "GoogleUtilities/NSData+zlib (6.5.0)" - - GoogleUtilities/Reachability (6.5.0): + - "GoogleUtilities/NSData+zlib (7.6.0)" + - GoogleUtilities/Reachability (7.6.0): - GoogleUtilities/Logger - - GoogleUtilities/UserDefaults (6.5.0): + - GoogleUtilities/UserDefaults (7.6.0): - GoogleUtilities/Logger - - "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.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.21.0) - - nanopb (~> 0.3) - - gRPC-Core/Interface (1.21.0) - - GTMSessionFetcher/Core (1.3.1) - - leveldb-library (1.22) - - nanopb (0.3.9011): - - nanopb/decode (= 0.3.9011) - - nanopb/encode (= 0.3.9011) - - nanopb/decode (0.3.9011) - - nanopb/encode (0.3.9011) - - path_provider_linux (0.0.1): - - Flutter - - PromisesObjC (1.2.8) - - Protobuf (3.12.0) - - shared_preferences (0.0.1): - - Flutter - - shared_preferences_linux (0.0.1): - - Flutter - - shared_preferences_macos (0.0.1): - - Flutter - - shared_preferences_web (0.0.1): - - Flutter - - url_launcher (0.0.1): - - Flutter - - url_launcher_linux (0.0.1): - - Flutter - - url_launcher_macos (0.0.1): + - "gRPC-C++ (1.28.2)": + - "gRPC-C++/Implementation (= 1.28.2)" + - "gRPC-C++/Interface (= 1.28.2)" + - "gRPC-C++/Implementation (1.28.2)": + - abseil/container/inlined_vector (= 0.20200225.0) + - abseil/memory/memory (= 0.20200225.0) + - abseil/strings/str_format (= 0.20200225.0) + - abseil/strings/strings (= 0.20200225.0) + - abseil/types/optional (= 0.20200225.0) + - "gRPC-C++/Interface (= 1.28.2)" + - gRPC-Core (= 1.28.2) + - "gRPC-C++/Interface (1.28.2)" + - gRPC-Core (1.28.2): + - gRPC-Core/Implementation (= 1.28.2) + - gRPC-Core/Interface (= 1.28.2) + - gRPC-Core/Implementation (1.28.2): + - abseil/container/inlined_vector (= 0.20200225.0) + - abseil/memory/memory (= 0.20200225.0) + - abseil/strings/str_format (= 0.20200225.0) + - abseil/strings/strings (= 0.20200225.0) + - abseil/types/optional (= 0.20200225.0) + - BoringSSL-GRPC (= 0.0.7) + - gRPC-Core/Interface (= 1.28.2) + - gRPC-Core/Interface (1.28.2) + - GTMSessionFetcher/Core (1.7.0) + - leveldb-library (1.22.1) + - nanopb (2.30908.0): + - nanopb/decode (= 2.30908.0) + - nanopb/encode (= 2.30908.0) + - nanopb/decode (2.30908.0) + - nanopb/encode (2.30908.0) + - PromisesObjC (2.0.0) + - shared_preferences_ios (0.0.1): - Flutter - - url_launcher_web (0.0.1): + - url_launcher_ios (0.0.1): - Flutter DEPENDENCIES: - cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) - - cloud_firestore_web (from `.symlinks/plugins/cloud_firestore_web/ios`) - firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) - firebase_core (from `.symlinks/plugins/firebase_core/ios`) - - firebase_core_web (from `.symlinks/plugins/firebase_core_web/ios`) - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) - Flutter (from `Flutter`) - - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`) - - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - - shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`) - - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) - - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) - - url_launcher (from `.symlinks/plugins/url_launcher/ios`) - - url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`) - - url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`) - - url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`) + - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) SPEC REPOS: trunk: - abseil - BoringSSL-GRPC - Firebase - - FirebaseAnalytics - - FirebaseAnalyticsInterop - FirebaseAuth - - FirebaseAuthInterop - FirebaseCore - FirebaseCoreDiagnostics - - FirebaseCoreDiagnosticsInterop - FirebaseFirestore - FirebaseInstallations - - FirebaseInstanceID - FirebaseMessaging - - GoogleAppMeasurement - GoogleDataTransport - - GoogleDataTransportCCTSupport - GoogleUtilities - "gRPC-C++" - gRPC-Core @@ -374,85 +498,49 @@ SPEC REPOS: - leveldb-library - nanopb - PromisesObjC - - Protobuf EXTERNAL SOURCES: cloud_firestore: :path: ".symlinks/plugins/cloud_firestore/ios" - cloud_firestore_web: - :path: ".symlinks/plugins/cloud_firestore_web/ios" firebase_auth: :path: ".symlinks/plugins/firebase_auth/ios" firebase_core: :path: ".symlinks/plugins/firebase_core/ios" - firebase_core_web: - :path: ".symlinks/plugins/firebase_core_web/ios" firebase_messaging: :path: ".symlinks/plugins/firebase_messaging/ios" Flutter: :path: Flutter - path_provider_linux: - :path: ".symlinks/plugins/path_provider_linux/ios" - shared_preferences: - :path: ".symlinks/plugins/shared_preferences/ios" - shared_preferences_linux: - :path: ".symlinks/plugins/shared_preferences_linux/ios" - shared_preferences_macos: - :path: ".symlinks/plugins/shared_preferences_macos/ios" - shared_preferences_web: - :path: ".symlinks/plugins/shared_preferences_web/ios" - url_launcher: - :path: ".symlinks/plugins/url_launcher/ios" - url_launcher_linux: - :path: ".symlinks/plugins/url_launcher_linux/ios" - url_launcher_macos: - :path: ".symlinks/plugins/url_launcher_macos/ios" - url_launcher_web: - :path: ".symlinks/plugins/url_launcher_web/ios" + shared_preferences_ios: + :path: ".symlinks/plugins/shared_preferences_ios/ios" + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" SPEC CHECKSUMS: - abseil: 18063d773f5366ff8736a050fe035a28f635fd27 - BoringSSL-GRPC: db8764df3204ccea016e1c8dd15d9a9ad63ff318 - cloud_firestore: 2a4f8f802fb0b701cf809b283b6bec7477ebaa6f - cloud_firestore_web: 9ec3dc7f5f98de5129339802d491c1204462bfec - Firebase: 5d77105d9740a07ca6b16927ca971db7e860faaf - firebase_auth: d99b993c1405096e66c58211b1cd956c23eed1c5 - firebase_core: 335c02abd48672b7c83c683df833d0488a72e73e - firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1 - firebase_messaging: 21344b3b3a7d9d325d63a70e3750c0c798fe1e03 - FirebaseAnalytics: e83e64b1231dedcd9ddd4bdecd9bcfd6ba341679 - FirebaseAnalyticsInterop: 3f86269c38ae41f47afeb43ebf32a001f58fcdae - FirebaseAuth: ce45d7c5d46bed90159f3a73b6efbe8976ed3573 - FirebaseAuthInterop: 0ffa57668be100582bb7643d4fcb7615496c41fc - FirebaseCore: 4aeb81ff53dcd9a3634ca725dc1fb8c2a4622046 - FirebaseCoreDiagnostics: 5e78803ab276bc5b50340e3c539c06c3de35c649 - FirebaseCoreDiagnosticsInterop: 296e2c5f5314500a850ad0b83e9e7c10b011a850 - FirebaseFirestore: b7e6adda31974dbd259fc25b541e8850420c92ed - FirebaseInstallations: 575cd32f2aec0feeb0e44f5d0110a09e5e60b47b - FirebaseInstanceID: 6668efc1655a4052c083f287a7141f1ead12f9c2 - FirebaseMessaging: 9e23f9d603b1fb71ccbeb48d79bf0d4ba0272c84 - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec - GoogleAppMeasurement: a08a43b8677b95ed51fcef880e36737334d804fd - GoogleDataTransport: 574a983e829327d7c18f2627f65d9e80164ea8a4 - GoogleDataTransportCCTSupport: cad3cd6cdbdbad6b5c2c9206ec413402755faaaa - GoogleUtilities: f8de7ddf8c706f58e9b405d53e38bbdaa2731e5a - "gRPC-C++": 9dfe7b44821e7b3e44aacad2af29d2c21f7cde83 - gRPC-Core: c9aef9a261a1247e881b18059b84d597293c9947 - GTMSessionFetcher: cea130bbfe5a7edc8d06d3f0d17288c32ffe9925 - leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7 - nanopb: 18003b5e52dab79db540fe93fe9579f399bd1ccd - path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 - PromisesObjC: c119f3cd559f50b7ae681fa59dc1acd19173b7e6 - Protobuf: 2793fcd0622a00b546c60e7cbbcc493e043e9bb9 - shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d - shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78 - shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 - shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 - url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef - url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0 - url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313 - url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c + abseil: 6c8eb7892aefa08d929b39f9bb108e5367e3228f + BoringSSL-GRPC: 8edf627ee524575e2f8d19d56f068b448eea3879 + cloud_firestore: 338122a6149c14ca376ad363626b5bf3037a5056 + Firebase: 13d8d96499e2635428d5bf0ec675df21f95d9a95 + firebase_auth: e875a50b81aefb20f305dfede425647e9675c19e + firebase_core: c263d7daf1dc92fcd9895e6abdc04872b0ee07ff + firebase_messaging: dff5cd08781ee1de988565a83c977e435405cd7e + FirebaseAuth: 2b78b2a32c07b3ecfa4970bdf1d3632b8304099b + FirebaseCore: 599ee609343eaf4941bd188f85e3aa077ffe325b + FirebaseCoreDiagnostics: 56fb7216d87e0e6ec2feddefa9d8a392fe8b2c18 + FirebaseFirestore: 15ae9648476436efed698a909e44c4737498f9b4 + FirebaseInstallations: 830327b45345ffc859eaa9c17bcd5ae893fd5425 + FirebaseMessaging: 82c4a48638f53f7b184f3cc9f6cd2cbe533ab316 + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + GoogleDataTransport: 629c20a4d363167143f30ea78320d5a7eb8bd940 + GoogleUtilities: 684ee790a24f73ebb2d1d966e9711c203f2a4237 + "gRPC-C++": 13d8ccef97d5c3c441b7e3c529ef28ebee86fad2 + gRPC-Core: 4afa11bfbedf7cdecd04de535a9e046893404ed5 + GTMSessionFetcher: 43748f93435c2aa068b1cbe39655aaf600652e91 + leveldb-library: 50c7b45cbd7bf543c81a468fe557a16ae3db8729 + nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96 + PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58 + shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32 + url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af -PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83 +PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 -COCOAPODS: 1.9.1 +COCOAPODS: 1.11.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index cbb6312..26d3262 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -167,7 +167,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -230,9 +230,46 @@ files = ( ); inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC/openssl_grpc.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseAuth/FirebaseAuth.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseFirestore/FirebaseFirestore.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseMessaging/FirebaseMessaging.framework", + "${BUILT_PRODUCTS_DIR}/GTMSessionFetcher/GTMSessionFetcher.framework", + "${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework", + "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework", + "${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework", + "${BUILT_PRODUCTS_DIR}/abseil/absl.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", + "${BUILT_PRODUCTS_DIR}/shared_preferences_ios/shared_preferences_ios.framework", + "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseAuth.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCore.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreDiagnostics.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseFirestore.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseInstallations.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseMessaging.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMSessionFetcher.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleDataTransport.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/absl.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", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_ios.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -311,7 +348,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -351,7 +387,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -373,7 +409,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -388,7 +427,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -434,7 +472,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -444,7 +482,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -484,7 +521,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -507,7 +544,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -534,7 +574,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..3db53b6 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ ( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Cyan') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Teal') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Purple') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Red') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.redAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.redAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Orange') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Yellow') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Green') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), child: MyApp(), ), ); @@ -232,7 +267,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { final themeNotifier = Provider.of(context); - return StreamProvider.value( + return StreamProvider.value( value: AuthService().user, child: MaterialApp( initialRoute: '/wrapper', @@ -249,8 +284,8 @@ class MyApp extends StatelessWidget { title: 'Share A Cab', builder: (context, child) { return MediaQuery( - child: child, data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), + child: child, ); }, debugShowCheckedModeBanner: false, @@ -264,28 +299,27 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { //print('dark theme is $darkTheme'); return darkTheme ? ThemeData( - primarySwatch: Colors.grey, bottomAppBarColor: const Color(0xFF212121), primaryColor: const Color(0xFF212121), primaryColorDark: Colors.black, brightness: Brightness.dark, backgroundColor: const Color(0xFF212121), - accentColor: accentColor, - accentIconTheme: IconThemeData(color: Colors.black), dividerColor: Colors.black12, scaffoldBackgroundColor: Colors.black, - textSelectionTheme: TextSelectionThemeData(cursorColor: Colors.white, selectionColor: Colors.blue, selectionHandleColor: Colors.blue), + textSelectionTheme: TextSelectionThemeData( + cursorColor: Colors.white, + selectionColor: Colors.blue, + selectionHandleColor: Colors.blue), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) + .copyWith(secondary: accentColor), ) : ThemeData( appBarTheme: AppBarTheme(color: Colors.black), - primarySwatch: Colors.grey, bottomAppBarColor: Color(0xFF212121), primaryColor: Colors.grey[600], primaryColorDark: Colors.grey[800], brightness: Brightness.light, backgroundColor: const Color(0xFFE5E5E5), - accentColor: accentColor, - accentIconTheme: IconThemeData(color: Colors.white), dividerColor: Colors.white54, scaffoldBackgroundColor: const Color(0xFFE5E5E5), textSelectionTheme: TextSelectionThemeData( @@ -293,5 +327,7 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { selectionColor: Colors.blueGrey[700], selectionHandleColor: Colors.blueGrey[700], ), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) + .copyWith(secondary: accentColor), ); } diff --git a/lib/screens/authenticate/change_email.dart b/lib/screens/authenticate/change_email.dart index f15a564..647aa68 100644 --- a/lib/screens/authenticate/change_email.dart +++ b/lib/screens/authenticate/change_email.dart @@ -20,7 +20,7 @@ class _ChangeEmailState extends State { @override Widget build(BuildContext context) { - var currentuser = Provider.of(context); + var currentuser = Provider.of(context); if (currentuser != null) { setState(() { originalEmail = currentuser.email; @@ -43,7 +43,18 @@ class _ChangeEmailState extends State { SizedBox(height: 20.0), TextFormField( initialValue: originalEmail, - decoration: InputDecoration(hintText: 'Email', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration( + hintText: 'Email', + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: + getBorderColorForInputFields(context), + width: 2.0)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: + Theme.of(context).colorScheme.secondary, + width: 2.0))), validator: (val) { if (val.isEmpty) { return 'Enter a valid Email'; @@ -68,7 +79,8 @@ class _ChangeEmailState extends State { ), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary), ), child: Text( 'Change Email', @@ -82,7 +94,8 @@ class _ChangeEmailState extends State { }); await _auth.changeEmail(email); await _auth.signOut(); - await Navigator.pushNamedAndRemoveUntil(context, '/wrapper', (route) => false); + await Navigator.pushNamedAndRemoveUntil( + context, '/wrapper', (route) => false); setState(() { loading = false; }); @@ -95,7 +108,8 @@ class _ChangeEmailState extends State { error = 'Your email is invalid'; break; case 'ERROR_EMAIL_ALREADY_IN_USE': - error = 'Email is already in use on different account'; + error = + 'Email is already in use on different account'; break; default: error = 'An undefined Error happened.'; @@ -109,7 +123,8 @@ class _ChangeEmailState extends State { SizedBox(height: 24.0), Text( 'Once you change your email, please log-in again by entering your new email ID and your previous password.', - style: TextStyle(fontSize: 17.0, fontStyle: FontStyle.italic), + style: TextStyle( + fontSize: 17.0, fontStyle: FontStyle.italic), textAlign: TextAlign.justify, ), SizedBox( diff --git a/lib/screens/authenticate/forgotpass.dart b/lib/screens/authenticate/forgotpass.dart index 8027b8c..38bf842 100644 --- a/lib/screens/authenticate/forgotpass.dart +++ b/lib/screens/authenticate/forgotpass.dart @@ -42,7 +42,7 @@ class _ForgotPassState extends State { SizedBox(height: 100.0), CircleAvatar( radius: 48, - backgroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).colorScheme.secondary, child: Icon( CupertinoIcons.car_detailed, size: 48, @@ -50,7 +50,7 @@ class _ForgotPassState extends State { ), SizedBox(height: 30.0), TextFormField( - decoration: InputDecoration(hintText: 'Email', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration(hintText: 'Email', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), validator: (val) => val.isEmpty ? 'Enter a valid Email' : null, onChanged: (val) { setState(() => email = val); @@ -59,7 +59,7 @@ class _ForgotPassState extends State { SizedBox(height: 20.0), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 14.0), @@ -109,7 +109,7 @@ class _ForgotPassState extends State { SizedBox(height: 15.0), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 14.0), diff --git a/lib/screens/authenticate/register.dart b/lib/screens/authenticate/register.dart index de34aa1..b7876d1 100644 --- a/lib/screens/authenticate/register.dart +++ b/lib/screens/authenticate/register.dart @@ -113,7 +113,7 @@ class _RegisterState extends State { SizedBox(height: 20.0), CircleAvatar( radius: 48, - backgroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).colorScheme.secondary, child: Icon( CupertinoIcons.car_detailed, size: 48, @@ -125,7 +125,7 @@ class _RegisterState extends State { decoration: InputDecoration( hintText: 'Email', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0)), + focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0)), ), validator: (val) { if (val.isEmpty) { @@ -151,7 +151,7 @@ class _RegisterState extends State { decoration: InputDecoration( hintText: 'Password', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0)), + focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0)), suffixIcon: IconButton( icon: Icon( passwordHide ? Icons.visibility_off : Icons.visibility, @@ -175,7 +175,7 @@ class _RegisterState extends State { decoration: InputDecoration( hintText: 'Confirm Password', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0)), + focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0)), suffixIcon: IconButton( icon: Icon( passwordHide ? Icons.visibility_off : Icons.visibility, @@ -205,7 +205,7 @@ class _RegisterState extends State { SizedBox(height: 20.0), TextFormField( textCapitalization: TextCapitalization.words, - decoration: InputDecoration(hintText: 'Name', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration(hintText: 'Name', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), validator: (val) => val.isEmpty ? 'Enter a valid Name' : null, onChanged: (val) { setState(() => name = val); @@ -213,7 +213,7 @@ class _RegisterState extends State { ), SizedBox(height: 20.0), TextFormField( - decoration: InputDecoration(hintText: 'Mobile Number', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration(hintText: 'Mobile Number', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), validator: (val) => val.length != 10 ? 'Enter a valid mobile number.' : null, keyboardType: TextInputType.number, inputFormatters: [FilteringTextInputFormatter.digitsOnly], @@ -223,7 +223,7 @@ class _RegisterState extends State { ), SizedBox(height: 20.0), DropdownButtonFormField( - decoration: InputDecoration(hintText: 'Select Hostel', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration(hintText: 'Select Hostel', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), value: hostel, onTap: () => FocusScope.of(context).requestFocus(FocusNode()), onChanged: (newValue) { @@ -234,15 +234,15 @@ class _RegisterState extends State { }, items: _hostels.map((temp) { return DropdownMenuItem( - child: Text(temp), value: temp, + child: Text(temp), ); }).toList(), validator: (val) => val == null ? 'Please select your hostel' : null, ), SizedBox(height: 20.0), DropdownButtonFormField( - decoration: InputDecoration(hintText: 'Select Gender', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration(hintText: 'Select Gender', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), value: sex, onTap: () => FocusScope.of(context).requestFocus(FocusNode()), onChanged: (newValue) { @@ -253,8 +253,8 @@ class _RegisterState extends State { }, items: _sex.map((temp) { return DropdownMenuItem( - child: Text(temp), value: temp, + child: Text(temp), ); }).toList(), validator: (val) => val == null ? 'Please select your sex' : null, @@ -262,7 +262,7 @@ class _RegisterState extends State { SizedBox(height: 20.0), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 17.0), @@ -283,7 +283,7 @@ class _RegisterState extends State { pr.style( message: 'Signing up...', backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle(color: Theme.of(context).accentColor), + messageTextStyle: TextStyle(color: Theme.of(context).colorScheme.secondary), ); await pr.show(); await Future.delayed(Duration(seconds: 1)); @@ -314,7 +314,7 @@ class _RegisterState extends State { duration: Duration(seconds: 2), content: Text( error, - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), )); } diff --git a/lib/screens/authenticate/sign_in.dart b/lib/screens/authenticate/sign_in.dart index 64529c6..0348e14 100644 --- a/lib/screens/authenticate/sign_in.dart +++ b/lib/screens/authenticate/sign_in.dart @@ -82,7 +82,7 @@ class _SignInState extends State { SizedBox(height: 20.0), CircleAvatar( radius: 48, - backgroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).colorScheme.secondary, child: Icon( CupertinoIcons.car_detailed, size: 48, @@ -107,7 +107,7 @@ class _SignInState extends State { ), SizedBox(height: 20.0), TextFormField( - decoration: InputDecoration(hintText: 'Email', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration(hintText: 'Email', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), validator: (val) => val.isEmpty ? 'Enter a valid Email' : null, onChanged: (val) { setState(() => email = val); @@ -118,7 +118,7 @@ class _SignInState extends State { decoration: InputDecoration( hintText: 'Password', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0)), + focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0)), suffixIcon: IconButton( icon: Icon( passwordHide ? Icons.visibility_off : Icons.visibility, @@ -140,7 +140,7 @@ class _SignInState extends State { SizedBox(height: 20.0), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 16), @@ -178,7 +178,7 @@ class _SignInState extends State { duration: Duration(seconds: 2), content: Text( error, - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), )); } @@ -217,7 +217,7 @@ class _SignInState extends State { duration: Duration(seconds: 2), content: Text( error, - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), )); } @@ -228,7 +228,7 @@ class _SignInState extends State { SizedBox(height: 20.0), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 16), diff --git a/lib/screens/authenticate/verified_email_check.dart b/lib/screens/authenticate/verified_email_check.dart index cb472eb..b7a1ae4 100644 --- a/lib/screens/authenticate/verified_email_check.dart +++ b/lib/screens/authenticate/verified_email_check.dart @@ -28,13 +28,13 @@ class _VerificationCheckState extends State { Future(() async { Timer.periodic(Duration(seconds: 5), (timer) async { - // FirebaseUser - var olduser = await FirebaseAuth.instance.currentUser(); + // User + var olduser = FirebaseAuth.instance.currentUser; await olduser.reload(); - var user = await FirebaseAuth.instance.currentUser(); - if (user.isEmailVerified) { + var user = FirebaseAuth.instance.currentUser; + if (user.emailVerified) { setState(() { - verified = user.isEmailVerified; + verified = user.emailVerified; }); timer.cancel(); } @@ -44,7 +44,7 @@ class _VerificationCheckState extends State { @override Widget build(BuildContext context) { - var currentuser = Provider.of(context); + var currentuser = Provider.of(context); email = currentuser.email; @@ -76,7 +76,8 @@ class _VerificationCheckState extends State { }, label: Text( 'Logout', - style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle( + color: getVisibleColorOnPrimaryColor(context)), ), ) ], @@ -90,14 +91,21 @@ class _VerificationCheckState extends State { SizedBox(height: 20.0), RichText( text: TextSpan( - text: 'Verification email has been sent to your ID. Please click on the verification link in your mail.', - style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold, color: getBorderColorForInputFields(context)), + text: + 'Verification email has been sent to your ID. Please click on the verification link in your mail.', + style: TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.bold, + color: getBorderColorForInputFields(context)), )), SizedBox(height: 30.0), RichText( text: TextSpan( - text: 'The registered email id is: ${email}', - style: TextStyle(fontSize: 17.0, color: getBorderColorForInputFields(context), fontWeight: FontWeight.w700), + text: 'The registered email id is: $email', + style: TextStyle( + fontSize: 17.0, + color: getBorderColorForInputFields(context), + fontWeight: FontWeight.w700), ), ), SizedBox( @@ -108,11 +116,13 @@ class _VerificationCheckState extends State { children: [ ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary), ), child: Text( 'Resend email', - style: TextStyle(color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + color: getVisibleColorOnAccentColor(context)), ), onPressed: () { try { @@ -128,14 +138,19 @@ class _VerificationCheckState extends State { ), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary), ), child: Text( 'Change email', - style: TextStyle(color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + color: getVisibleColorOnAccentColor(context)), ), onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => ChangeEmail())); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeEmail())); }, ), ], @@ -143,8 +158,12 @@ class _VerificationCheckState extends State { SizedBox(height: 20.0), RichText( text: TextSpan( - text: 'You will be auto-redirected to dashboard once you verify your account.', - style: TextStyle(color: Colors.red, fontSize: 20.0, fontStyle: FontStyle.italic), + text: + 'You will be auto-redirected to dashboard once you verify your account.', + style: TextStyle( + color: Colors.red, + fontSize: 20.0, + fontStyle: FontStyle.italic), )), SizedBox(height: 20.0), ], diff --git a/lib/screens/chatscreen/chat_database/database.dart b/lib/screens/chatscreen/chat_database/database.dart index b4bd679..43c5284 100644 --- a/lib/screens/chatscreen/chat_database/database.dart +++ b/lib/screens/chatscreen/chat_database/database.dart @@ -4,39 +4,42 @@ import 'package:firebase_auth/firebase_auth.dart'; class ChatDatabase { final _auth = FirebaseAuth.instance; - final CollectionReference chatLists = Firestore.instance.collection('chatroom'); - final CollectionReference group = Firestore.instance.collection('group'); + final CollectionReference chatLists = + FirebaseFirestore.instance.collection('chatroom'); + final CollectionReference group = + FirebaseFirestore.instance.collection('group'); //adding user to chat room - Future createChatRoom(String docId, String uid, String destination) async { - var user = await _auth.currentUser(); - await chatLists.document(docId).setData({ + Future createChatRoom( + String docId, String uid, String destination) async { + var user = _auth.currentUser; + await chatLists.doc(docId).set({ 'lastMessage': Timestamp.now(), 'destination': destination, 'users': FieldValue.arrayUnion([user.uid]), }); - chatLists.document(docId).collection('chats'); + chatLists.doc(docId).collection('chats'); } //deleting user from group chat Future exitChatRoom(String docId) async { - var user = await _auth.currentUser(); - await chatLists.document(docId).updateData({ + var user = _auth.currentUser; + await chatLists.doc(docId).update({ 'users': FieldValue.arrayRemove([user.uid.toString()]) }); } //adding user to chat group Future joinGroup(String listuid) async { - var user = await _auth.currentUser(); - await chatLists.document(listuid).updateData({ + var user = _auth.currentUser; + await chatLists.doc(listuid).update({ 'users': FieldValue.arrayUnion([user.uid.toString()]), }); } // kicking a user from chat group Future kickedChatRoom(String groupID, String userID) async { - await chatLists.document(groupID).updateData({ + await chatLists.doc(groupID).update({ 'users': FieldValue.arrayRemove([userID.toString()]) }); } diff --git a/lib/screens/chatscreen/chat_screen.dart b/lib/screens/chatscreen/chat_screen.dart index 3ad7a2a..67496bd 100644 --- a/lib/screens/chatscreen/chat_screen.dart +++ b/lib/screens/chatscreen/chat_screen.dart @@ -18,7 +18,7 @@ class ChatScreen extends StatefulWidget { class _ChatScreenState extends State { //Set device token for current user final RequestService _request = RequestService(); - final FirebaseMessaging _fbm = FirebaseMessaging(); + final FirebaseMessaging _fbm = FirebaseMessaging.instance; Future _getToken() async { await _fbm.getToken().then((token) { _request.setDeviceToken(token); @@ -27,18 +27,7 @@ class _ChatScreenState extends State { @override void initState() { - final fbm = FirebaseMessaging(); - fbm.requestNotificationPermissions(); - fbm.configure(onMessage: (msg) { - print(msg); - return; - }, onLaunch: (msg) { - print(msg); - return; - }, onResume: (msg) { - print(msg); - return; - }); + final fbm = FirebaseMessaging.instance..requestPermission(); _getToken(); super.initState(); } diff --git a/lib/screens/chatscreen/chat_widgets/chat_bubble.dart b/lib/screens/chatscreen/chat_widgets/chat_bubble.dart index dd9632e..4d76cbf 100644 --- a/lib/screens/chatscreen/chat_widgets/chat_bubble.dart +++ b/lib/screens/chatscreen/chat_widgets/chat_bubble.dart @@ -13,6 +13,7 @@ class MessageBubble extends StatelessWidget { @override Widget build(BuildContext context) { return Stack( + clipBehavior: Clip.none, children: [ Row( mainAxisAlignment: isMe ? MainAxisAlignment.end : MainAxisAlignment.start, @@ -21,7 +22,7 @@ class MessageBubble extends StatelessWidget { children: [ Container( decoration: BoxDecoration( - color: isMe ? Colors.grey : Theme.of(context).accentColor, + color: isMe ? Colors.grey : Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.only( topLeft: Radius.circular(12), topRight: Radius.circular(12), @@ -80,7 +81,6 @@ class MessageBubble extends StatelessWidget { ], ), ], - clipBehavior: Clip.none, ); } } diff --git a/lib/screens/chatscreen/chat_widgets/chat_tile.dart b/lib/screens/chatscreen/chat_widgets/chat_tile.dart index fba0725..d1d0e0a 100644 --- a/lib/screens/chatscreen/chat_widgets/chat_tile.dart +++ b/lib/screens/chatscreen/chat_widgets/chat_tile.dart @@ -22,14 +22,14 @@ class _ChatTileState extends State { padding: EdgeInsets.symmetric(vertical: 15), decoration: BoxDecoration( border: Border( - bottom: BorderSide(width: 0.15, color: Theme.of(context).accentColor), + bottom: BorderSide(width: 0.15, color: Theme.of(context).colorScheme.secondary), )), child: ListTile( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => ChatScreen(widget.docId))); }, leading: CircleAvatar( - backgroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).colorScheme.secondary, radius: 30, child: Padding( padding: EdgeInsets.all(6), diff --git a/lib/screens/chatscreen/chat_widgets/chat_users_list.dart b/lib/screens/chatscreen/chat_widgets/chat_users_list.dart index ad837ea..0967a4a 100644 --- a/lib/screens/chatscreen/chat_widgets/chat_users_list.dart +++ b/lib/screens/chatscreen/chat_widgets/chat_users_list.dart @@ -5,15 +5,20 @@ import 'package:provider/provider.dart'; import './chat_tile.dart'; class ChatUsersList extends StatelessWidget { - static FirebaseUser user; + static User user; static DateTime range; @override Widget build(BuildContext context) { // Currently showing the chats of last 30 days only. range = DateTime.now().subtract(Duration(days: 30)); - final user = Provider.of(context); + final user = Provider.of(context); return StreamBuilder( - stream: Firestore.instance.collection('chatroom').where('users', arrayContains: user.uid).where('lastMessage', isGreaterThan: range).orderBy('lastMessage', descending: true).snapshots(), + stream: FirebaseFirestore.instance + .collection('chatroom') + .where('users', arrayContains: user.uid) + .where('lastMessage', isGreaterThan: range) + .orderBy('lastMessage', descending: true) + .snapshots(), builder: (ctx, futureSnapshot) { if (futureSnapshot.connectionState == ConnectionState.waiting) { return Center( @@ -21,11 +26,14 @@ class ChatUsersList extends StatelessWidget { ); } return ListView.builder( - itemCount: futureSnapshot.data == null ? 0 : futureSnapshot.data.documents.length, + itemCount: + futureSnapshot.data == null ? 0 : futureSnapshot.data.docs.length, itemBuilder: (context, index) { - final docId = futureSnapshot.data.documents[index].documentID; - final destination = futureSnapshot.data.documents[index].data['destination']; - final lastMessage = futureSnapshot.data.documents[index].data['lastMessage']; + final docId = futureSnapshot.data.docs[index].id; + final destination = + futureSnapshot.data.docs[index].data()['destination']; + final lastMessage = + futureSnapshot.data.docs[index].data()['lastMessage']; return ChatTile(docId, destination, lastMessage); }, ); diff --git a/lib/screens/chatscreen/chat_widgets/message.dart b/lib/screens/chatscreen/chat_widgets/message.dart index 3f28277..cc72a0e 100644 --- a/lib/screens/chatscreen/chat_widgets/message.dart +++ b/lib/screens/chatscreen/chat_widgets/message.dart @@ -11,50 +11,41 @@ class MessageScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return FutureBuilder( - future: FirebaseAuth.instance.currentUser(), - builder: (ctx, futureSnapshot) { - if (futureSnapshot.connectionState == ConnectionState.waiting) { - return Center( - child: CircularProgressIndicator(), - ); - } - return StreamBuilder( - stream: Firestore.instance - .collection('chatroom') - .document(docId) - .collection('chats') - .orderBy( - 'createdAt', - descending: true, - ) - .limit(30) - .snapshots(), - builder: (ctx, chatSnapshot) { - if (chatSnapshot.connectionState == ConnectionState.waiting) { - return Center( - child: CircularProgressIndicator(), - ); - } - final chatDocs = chatSnapshot.data.documents; + return StreamBuilder( + stream: FirebaseFirestore.instance + .collection('chatroom') + .doc(docId) + .collection('chats') + .orderBy( + 'createdAt', + descending: true, + ) + .limit(30) + .snapshots(), + builder: (ctx, chatSnapshot) { + if (chatSnapshot.connectionState == ConnectionState.waiting) { + return Center( + child: CircularProgressIndicator(), + ); + } + final chatDocs = chatSnapshot.data.docs; - return ListView.builder( - reverse: true, - itemCount: chatDocs.length, - itemBuilder: (ctx, index) => MessageBubble( - chatDocs[index]['text'], - chatDocs[index]['name'], - chatDocs[index]['userId'] == futureSnapshot.data.uid, - key: ValueKey(chatDocs[index].documentID), - time: DateFormat().add_jm().format( - DateTime.parse( - chatDocs[index]['createdAt'].toDate().toString(), - ), - ), - ), - ); - }); - }, - ); + return ListView.builder( + reverse: true, + itemCount: chatDocs.length, + itemBuilder: (ctx, index) => MessageBubble( + chatDocs[index]['text'], + chatDocs[index]['name'], + chatDocs[index]['userId'] == + FirebaseAuth.instance.currentUser.uid, + key: ValueKey(chatDocs[index].id), + time: DateFormat().add_jm().format( + DateTime.parse( + chatDocs[index]['createdAt'].toDate().toString(), + ), + ), + ), + ); + }); } } diff --git a/lib/screens/chatscreen/chat_widgets/new_message.dart b/lib/screens/chatscreen/chat_widgets/new_message.dart index af76c31..ee6a945 100644 --- a/lib/screens/chatscreen/chat_widgets/new_message.dart +++ b/lib/screens/chatscreen/chat_widgets/new_message.dart @@ -18,12 +18,22 @@ class _NewMessageState extends State { void _sendMessage() async { FocusScope.of(context).unfocus(); _controller.clear(); - final user = await FirebaseAuth.instance.currentUser(); - final userData = await Firestore.instance.collection('userdetails').document(user.uid).get(); - await Firestore.instance.collection('chatroom').document(widget.docId).updateData({ + final user = FirebaseAuth.instance.currentUser; + final userData = await FirebaseFirestore.instance + .collection('userdetails') + .doc(user.uid) + .get(); + await FirebaseFirestore.instance + .collection('chatroom') + .doc(widget.docId) + .update({ 'lastMessage': Timestamp.now(), }); - await Firestore.instance.collection('chatroom').document(widget.docId).collection('chats').add({ + await FirebaseFirestore.instance + .collection('chatroom') + .doc(widget.docId) + .collection('chats') + .add({ 'text': _enteredMessage, 'createdAt': Timestamp.now(), 'userId': user.uid, @@ -56,7 +66,7 @@ class _NewMessageState extends State { IconButton( icon: Icon( Icons.send, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), onPressed: _enteredMessage.trim().isEmpty ? null : _sendMessage, ) diff --git a/lib/screens/createtrip.dart b/lib/screens/createtrip.dart index a60d667..6b9a3e7 100644 --- a/lib/screens/createtrip.dart +++ b/lib/screens/createtrip.dart @@ -57,7 +57,7 @@ class _CreateTripState extends State { ScaffoldMessenger.of(context).showSnackBar(SnackBar( duration: Duration(seconds: 1), backgroundColor: Theme.of(context).primaryColor, - content: Text('One or more fields is missing', style: TextStyle(color: Theme.of(context).accentColor)), + content: Text('One or more fields is missing', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), )); return; //return stops function execution and thus nothing is called or returned } else if (_selectedStartDate == null || _selectedStartTime == null || _selectedEndDate == null || _selectedEndTime == null) { @@ -65,7 +65,7 @@ class _CreateTripState extends State { ScaffoldMessenger.of(context).showSnackBar(SnackBar( duration: Duration(seconds: 1), backgroundColor: Theme.of(context).primaryColor, - content: Text('Date or Time is missing', style: TextStyle(color: Theme.of(context).accentColor)), + content: Text('Date or Time is missing', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), )); return; } else { @@ -84,7 +84,7 @@ class _CreateTripState extends State { duration: Duration(seconds: 2), content: Text( 'INVALID : Start Time > End Time', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), )); } @@ -176,7 +176,7 @@ class _CreateTripState extends State { IconButton( icon: Icon( Icons.calendar_today, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), onPressed: () => DatePicker(), ), @@ -184,7 +184,7 @@ class _CreateTripState extends State { IconButton( icon: Icon( Icons.schedule, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), onPressed: () => TimePicker(), ), @@ -241,7 +241,7 @@ class _CreateTripState extends State { child: Text( dropDownStringItem, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), ), ); @@ -292,7 +292,7 @@ class _CreateTripState extends State { child: Text( dropDownIntItem.toString(), style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), ), ); @@ -323,7 +323,7 @@ class _CreateTripState extends State { children: [ Checkbox( checkColor: getVisibleColorOnAccentColor(context), - activeColor: Theme.of(context).accentColor, + activeColor: Theme.of(context).colorScheme.secondary, value: privacy, onChanged: (bool value) { setState(() { @@ -347,7 +347,7 @@ class _CreateTripState extends State { ), child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).accentColor, + primary: Theme.of(context).colorScheme.secondary, textStyle: TextStyle(color: getVisibleColorOnAccentColor(context)), ), onPressed: () { diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index a67532d..95582af 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -8,7 +8,7 @@ import 'package:shareacab/models/requestdetails.dart'; import 'package:shareacab/screens/createtrip.dart'; import 'package:shareacab/screens/filter.dart'; import 'package:shareacab/screens/help.dart'; -import 'package:shareacab/screens/settings.dart'; +import 'package:shareacab/screens/settings.dart' as SettingsScreen; import 'package:shareacab/screens/tripslist.dart'; import 'package:shareacab/services/auth.dart'; @@ -17,7 +17,8 @@ class Dashboard extends StatefulWidget { _DashboardState createState() => _DashboardState(); } -class _DashboardState extends State with AutomaticKeepAliveClientMixin { +class _DashboardState extends State + with AutomaticKeepAliveClientMixin { final GlobalKey scaffoldKey = GlobalKey(); final AuthService _auth = AuthService(); List filtered = allTrips; @@ -53,7 +54,7 @@ class _DashboardState extends State with AutomaticKeepAliveClientMixi var inGroupFetch = false; var UID; Future getCurrentUser() async { - var user = await auth.currentUser(); + var user = auth.currentUser; final userid = user.uid; setState(() { UID = userid; @@ -72,14 +73,16 @@ class _DashboardState extends State with AutomaticKeepAliveClientMixi Widget build(BuildContext context) { var fetched = false; super.build(context); - final currentuser = Provider.of(context); + final currentuser = Provider.of(context); return Scaffold( key: scaffoldKey, appBar: AppBar( title: Text('Dashboard'), actions: [ TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom( + textStyle: + TextStyle(color: getVisibleColorOnPrimaryColor(context))), icon: Icon( Icons.filter_list, size: 30.0, @@ -93,23 +96,29 @@ class _DashboardState extends State with AutomaticKeepAliveClientMixi icon: Icon(Icons.help), tooltip: 'Help', onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => Help())); + Navigator.push( + context, MaterialPageRoute(builder: (context) => Help())); }, ), IconButton( icon: Icon(Icons.settings), tooltip: 'Settings', onPressed: () { - return Navigator.push(context, MaterialPageRoute(builder: (context) { - return Settings(_auth); + return Navigator.push(context, + MaterialPageRoute(builder: (context) { + return SettingsScreen.Settings(_auth); })); }), ], ), resizeToAvoidBottomInset: false, body: StreamBuilder( - stream: Firestore.instance.collection('userdetails').document(currentuser.uid).snapshots(), - builder: (BuildContext context, AsyncSnapshot snapshot) { + stream: FirebaseFirestore.instance + .collection('userdetails') + .doc(currentuser.uid) + .snapshots(), + builder: + (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.active) { var temp = snapshot.data['currentGroup']; if (temp != null) { @@ -123,14 +132,17 @@ class _DashboardState extends State with AutomaticKeepAliveClientMixi } try { - if (snapshot.connectionState == ConnectionState.active && fetched == true) { + if (snapshot.connectionState == ConnectionState.active && + fetched == true) { return Scaffold( body: SingleChildScrollView( child: Column( children: [ Container( margin: EdgeInsets.all(5), - height: (MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top) * 0.87, + height: (MediaQuery.of(context).size.height - + MediaQuery.of(context).padding.top) * + 0.87, width: double.infinity, child: TripsList( _dest, diff --git a/lib/screens/edituserdetails.dart b/lib/screens/edituserdetails.dart index 49cef96..d234ecc 100644 --- a/lib/screens/edituserdetails.dart +++ b/lib/screens/edituserdetails.dart @@ -45,7 +45,7 @@ class _EditFormState extends State { @override Widget build(BuildContext context) { - final user = Provider.of(context); + final user = Provider.of(context); return StreamBuilder( stream: DatabaseService(uid: user.uid).userData, builder: (context, snapshot) { @@ -87,12 +87,14 @@ class _EditFormState extends State { ), label: Text( 'Done', - style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle( + color: getVisibleColorOnPrimaryColor(context)), )) ], ), body: Container( - padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 60.0), + padding: + EdgeInsets.symmetric(vertical: 20.0, horizontal: 60.0), child: Form( key: _formKey, child: SingleChildScrollView( @@ -102,8 +104,21 @@ class _EditFormState extends State { TextFormField( // textCapitalization: TextCapitalization.words, initialValue: snapshot.data['name'], - decoration: InputDecoration(hintText: 'Name', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), - validator: (val) => val.isEmpty ? 'Enter a valid Name' : null, + decoration: InputDecoration( + hintText: 'Name', + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: getBorderColorForInputFields( + context), + width: 2.0)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .colorScheme + .secondary, + width: 2.0))), + validator: (val) => + val.isEmpty ? 'Enter a valid Name' : null, onChanged: (val) { setState(() => name = val); }, @@ -111,51 +126,98 @@ class _EditFormState extends State { SizedBox(height: 20.0), TextFormField( initialValue: snapshot.data['mobileNumber'], - decoration: InputDecoration(hintText: 'Mobile Number', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), - validator: (val) => val.length != 10 ? 'Enter a valid mobile number.' : null, + decoration: InputDecoration( + hintText: 'Mobile Number', + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: getBorderColorForInputFields( + context), + width: 2.0)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .colorScheme + .secondary, + width: 2.0))), + validator: (val) => val.length != 10 + ? 'Enter a valid mobile number.' + : null, keyboardType: TextInputType.number, - inputFormatters: [FilteringTextInputFormatter.digitsOnly], + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly + ], onChanged: (val) { setState(() => mobileNum = val); }, ), SizedBox(height: 20.0), DropdownButtonFormField( - decoration: InputDecoration(hintText: 'Select Hostel', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration( + hintText: 'Select Hostel', + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: getBorderColorForInputFields( + context), + width: 2.0)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .colorScheme + .secondary, + width: 2.0))), value: hostel ?? snapshot.data['hostel'], - onTap: () => FocusScope.of(context).requestFocus(FocusNode()), + onTap: () => FocusScope.of(context) + .requestFocus(FocusNode()), onChanged: (newValue) { setState(() { - FocusScope.of(context).requestFocus(FocusNode()); + FocusScope.of(context) + .requestFocus(FocusNode()); hostel = newValue; }); }, items: _hostels.map((temp) { return DropdownMenuItem( - child: Text(temp), value: temp, + child: Text(temp), ); }).toList(), - validator: (val) => val == null ? 'Please select your hostel' : null, + validator: (val) => val == null + ? 'Please select your hostel' + : null, ), SizedBox(height: 20.0), DropdownButtonFormField( - decoration: InputDecoration(hintText: 'Select Gender', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2.0))), + decoration: InputDecoration( + hintText: 'Select Gender', + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: getBorderColorForInputFields( + context), + width: 2.0)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .colorScheme + .secondary, + width: 2.0))), value: sex ?? snapshot.data['sex'], - onTap: () => FocusScope.of(context).requestFocus(FocusNode()), + onTap: () => FocusScope.of(context) + .requestFocus(FocusNode()), onChanged: (newValue) { setState(() { - FocusScope.of(context).requestFocus(FocusNode()); + FocusScope.of(context) + .requestFocus(FocusNode()); sex = newValue; }); }, items: _sex.map((temp) { return DropdownMenuItem( - child: Text(temp), value: temp, + child: Text(temp), ); }).toList(), - validator: (val) => val == null ? 'Please select your sex' : null, + validator: (val) => + val == null ? 'Please select your sex' : null, ), SizedBox(height: 20.0), ], diff --git a/lib/screens/filter.dart b/lib/screens/filter.dart index 85c455e..94a50a4 100644 --- a/lib/screens/filter.dart +++ b/lib/screens/filter.dart @@ -58,7 +58,7 @@ class _FilterState extends State { title: Text('Destination'), value: _dest, subtitle: Text('Select Preferred Destination'), - activeColor: Theme.of(context).accentColor, + activeColor: Theme.of(context).colorScheme.secondary, onChanged: (newValue) { setState(() { _dest = newValue; @@ -81,7 +81,7 @@ class _FilterState extends State { child: Text( dropDownStringItem, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), ), ); @@ -101,7 +101,7 @@ class _FilterState extends State { title: Text('Privacy'), value: _notPrivacy, subtitle: Text('Only see groups which are Free to Join'), - activeColor: Theme.of(context).accentColor, + activeColor: Theme.of(context).colorScheme.secondary, onChanged: (newValue) { setState(() { _notPrivacy = newValue; @@ -124,7 +124,7 @@ class _FilterState extends State { _submitData(); }, style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Text('Filter', style: TextStyle(fontSize: 16, color: getVisibleColorOnAccentColor(context))), ), diff --git a/lib/screens/groupdetailscreen/ended_group_details.dart b/lib/screens/groupdetailscreen/ended_group_details.dart index f9a848e..9d115c9 100644 --- a/lib/screens/groupdetailscreen/ended_group_details.dart +++ b/lib/screens/groupdetailscreen/ended_group_details.dart @@ -20,7 +20,8 @@ class EndedGroupDetails extends StatefulWidget { final numberOfMembers; final data; - EndedGroupDetails(this.destination, this.docId, this.privacy, this.start, this.end, this.numberOfMembers, this.data); + EndedGroupDetails(this.destination, this.docId, this.privacy, this.start, + this.end, this.numberOfMembers, this.data); static bool inGroup = false; @override @@ -29,8 +30,12 @@ class EndedGroupDetails extends StatefulWidget { class _EndedGroupDetailsState extends State { Future getUserDetails() async { - final userDetails = await Firestore.instance.collection('group').document(widget.docId).collection('users').getDocuments(); - return userDetails.documents; + final userDetails = await FirebaseFirestore.instance + .collection('group') + .doc(widget.docId) + .collection('users') + .get(); + return userDetails.docs; } var _fetchData; @@ -69,7 +74,8 @@ class _EndedGroupDetailsState extends State { body: Scaffold( body: NestedScrollView( controller: ScrollController(keepScrollOffset: true), - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { return []; }, body: SingleChildScrollView( @@ -78,8 +84,10 @@ class _EndedGroupDetailsState extends State { Hero( tag: widget.docId, child: Card( - color: Theme.of(context).accentColor, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(25.0))), + color: Theme.of(context).colorScheme.secondary, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(25.0))), elevation: 5, margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), child: Container( @@ -96,15 +104,20 @@ class _EndedGroupDetailsState extends State { margin: EdgeInsets.only( left: 20, ), - child: widget.destination == 'New Delhi Railway Station' + child: widget.destination == + 'New Delhi Railway Station' ? Icon( Icons.train, - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, size: 30, ) : Icon( Icons.airplanemode_active, - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, size: 30, )), ), @@ -117,7 +130,12 @@ class _EndedGroupDetailsState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('Started : ${DateFormat('dd.MM.yyyy - kk:mm a').format(widget.start)}', style: TextStyle(fontSize: 15.0, color: getVisibleColorOnAccentColor(context))), + Text( + 'Started : ${DateFormat('dd.MM.yyyy - kk:mm a').format(widget.start)}', + style: TextStyle( + fontSize: 15.0, + color: getVisibleColorOnAccentColor( + context))), ], ), ), @@ -130,7 +148,10 @@ class _EndedGroupDetailsState extends State { children: [ Text( 'Ended : ${DateFormat('dd.MM.yyyy - kk:mm a').format(widget.end)}', - style: TextStyle(fontSize: 15, color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + fontSize: 15, + color: getVisibleColorOnAccentColor( + context)), ), ], ), @@ -143,7 +164,9 @@ class _EndedGroupDetailsState extends State { Text( 'Number of members in group: ' '${widget.numberOfMembers}', - style: TextStyle(color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + color: getVisibleColorOnAccentColor( + context)), ) ], ), @@ -160,7 +183,8 @@ class _EndedGroupDetailsState extends State { child: FutureBuilder( future: _fetchData, builder: (ctx, futureSnapshot) { - if (futureSnapshot.connectionState == ConnectionState.waiting) { + if (futureSnapshot.connectionState == + ConnectionState.waiting) { return Center( child: CircularProgressIndicator(), ); @@ -170,20 +194,26 @@ class _EndedGroupDetailsState extends State { itemCount: futureSnapshot.data.length, itemBuilder: (ctx, index) { return Container( - margin: EdgeInsets.symmetric(vertical: 2, horizontal: 10), + margin: EdgeInsets.symmetric( + vertical: 2, horizontal: 10), width: double.infinity, child: Card( elevation: 4, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.all(8.0), - child: Text(futureSnapshot.data[index].data['name']), + child: Text(futureSnapshot + .data()[index] + .data()['name']), ), Padding( padding: const EdgeInsets.all(8.0), - child: Text(futureSnapshot.data[index].data['hostel']), + child: Text(futureSnapshot + .data()[index] + .data()['hostel']), ), Padding( padding: const EdgeInsets.all(8.0), @@ -191,39 +221,66 @@ class _EndedGroupDetailsState extends State { onPressed: () async { try { if (Platform.isIOS) { - await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data[index].data['mobilenum'].toString()}')).then((result) { + await Clipboard.setData( + ClipboardData( + text: + '${futureSnapshot.data()[index].data()['mobilenum'].toString()}')) + .then((result) { final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, + backgroundColor: + Theme.of(context) + .primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle( + color: + getVisibleColorOnPrimaryColor( + context)), ), - duration: Duration(seconds: 1), + duration: + Duration(seconds: 1), ); - ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); - ScaffoldMessenger.of(ctx).showSnackBar(snackBar); + ScaffoldMessenger.of(ctx) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(ctx) + .showSnackBar(snackBar); }); } else { - await launch('tel://${futureSnapshot.data[index].data['mobilenum'].toString()}'); + await launch( + 'tel://${futureSnapshot.data()[index].data()['mobilenum'].toString()}'); } } catch (e) { - await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data[index].data['mobilenum'].toString()}')).then((result) { + await Clipboard.setData( + ClipboardData( + text: + '${futureSnapshot.data()[index].data()['mobilenum'].toString()}')) + .then((result) { final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, + backgroundColor: + Theme.of(context) + .primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle( + color: + getVisibleColorOnPrimaryColor( + context)), ), - duration: Duration(seconds: 1), + duration: + Duration(seconds: 1), ); - ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); - ScaffoldMessenger.of(ctx).showSnackBar(snackBar); + ScaffoldMessenger.of(ctx) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(ctx) + .showSnackBar(snackBar); }); } }, icon: Icon( Icons.phone, - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, )), ), ], diff --git a/lib/screens/groupdetailscreen/groupdetails.dart b/lib/screens/groupdetailscreen/groupdetails.dart index eab1d1d..5a1818c 100644 --- a/lib/screens/groupdetailscreen/groupdetails.dart +++ b/lib/screens/groupdetailscreen/groupdetails.dart @@ -27,18 +27,24 @@ class GroupDetails extends StatefulWidget { final numberOfMembers; final data; - GroupDetails(this.destination, this.docId, this.privacy, this.start, this.end, this.numberOfMembers, this.data); + GroupDetails(this.destination, this.docId, this.privacy, this.start, this.end, + this.numberOfMembers, this.data); static bool inGroup = false; @override _GroupDetailsState createState() => _GroupDetailsState(); } -class _GroupDetailsState extends State with AutomaticKeepAliveClientMixin { +class _GroupDetailsState extends State + with AutomaticKeepAliveClientMixin { final RequestService _request = RequestService(); final NotifServices _notifServices = NotifServices(); Future getUserDetails() async { - final userDetails = await Firestore.instance.collection('group').document(widget.docId).collection('users').snapshots(); + final userDetails = FirebaseFirestore.instance + .collection('group') + .doc(widget.docId) + .collection('users') + .snapshots(); return userDetails; } @@ -65,29 +71,43 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie Widget build(BuildContext context) { super.build(context); timeDilation = 1.0; - final currentuser = Provider.of(context); + final currentuser = Provider.of(context); return StreamBuilder( - stream: Firestore.instance.collection('userdetails').document(currentuser.uid).snapshots(), + stream: FirebaseFirestore.instance + .collection('userdetails') + .doc(currentuser.uid) + .snapshots(), builder: (context, usersnapshot) { - requestedToJoin = usersnapshot.hasData ? usersnapshot.data['currentGroupJoinRequests'] != null && usersnapshot.data['currentGroupJoinRequests'].contains(widget.docId) : false; + requestedToJoin = usersnapshot.hasData + ? usersnapshot.data()['currentGroupJoinRequests'] != null && + usersnapshot + .data()['currentGroupJoinRequests'] + .contains(widget.docId) + : false; if (usersnapshot.connectionState == ConnectionState.active) { - var groupUID = usersnapshot.data['currentGroup']; + var groupUID = usersnapshot.data()['currentGroup']; if (groupUID != null) { GroupDetails.inGroup = true; } else { GroupDetails.inGroup = false; } return StreamBuilder( - stream: Firestore.instance.collection('group').document(widget.docId).snapshots(), + stream: FirebaseFirestore.instance + .collection('group') + .doc(widget.docId) + .snapshots(), builder: (context, groupsnapshot) { if (groupsnapshot.connectionState == ConnectionState.active) { - privacy = groupsnapshot.data['privacy']; - destination = groupsnapshot.data['destination']; - start = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data['start'].toDate()); - end = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data['end'].toDate()); - presentNum = groupsnapshot.data['numberOfMembers'].toString(); + privacy = groupsnapshot.data()['privacy']; + destination = groupsnapshot.data()['destination']; + start = DateFormat('dd.MM.yyyy - kk:mm a') + .format(groupsnapshot.data()['start'].toDate()); + end = DateFormat('dd.MM.yyyy - kk:mm a') + .format(groupsnapshot.data()['end'].toDate()); + presentNum = + groupsnapshot.data()['numberOfMembers'].toString(); present = int.parse(presentNum); - max = groupsnapshot.data['maxpoolers']; + max = groupsnapshot.data()['maxpoolers']; if (present >= max) { full = true; } else { @@ -95,7 +115,8 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie } return NestedScrollView( controller: ScrollController(keepScrollOffset: true), - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( pinned: true, @@ -109,8 +130,10 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie }, body: Scaffold( body: NestedScrollView( - controller: ScrollController(keepScrollOffset: true), - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + controller: + ScrollController(keepScrollOffset: true), + headerSliverBuilder: (BuildContext context, + bool innerBoxIsScrolled) { return []; }, body: SingleChildScrollView( @@ -119,16 +142,23 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie Hero( tag: widget.docId, child: Card( - color: Theme.of(context).accentColor, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(25.0))), + color: Theme.of(context) + .colorScheme + .secondary, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(25.0))), elevation: 5, - margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), + margin: EdgeInsets.symmetric( + vertical: 6, horizontal: 5), child: Container( height: 120, child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, children: [ Flexible( fit: FlexFit.tight, @@ -137,15 +167,24 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie margin: EdgeInsets.only( left: 20, ), - child: widget.destination == 'New Delhi Railway Station' + child: widget + .destination == + 'New Delhi Railway Station' ? Icon( Icons.train, - color: Theme.of(context).accentColor, + color: Theme.of( + context) + .colorScheme + .secondary, size: 30, ) : Icon( - Icons.airplanemode_active, - color: Theme.of(context).accentColor, + Icons + .airplanemode_active, + color: Theme.of( + context) + .colorScheme + .secondary, size: 30, )), ), @@ -156,9 +195,15 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie bottom: 5, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ - Text('Start : ${start}', style: TextStyle(fontSize: 15.0, color: getVisibleColorOnAccentColor(context))), + Text('Start : $start', + style: TextStyle( + fontSize: 15.0, + color: + getVisibleColorOnAccentColor( + context))), ], ), ), @@ -167,26 +212,37 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie bottom: 5, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( - 'End : ${end}', - style: TextStyle(fontSize: 15, color: getVisibleColorOnAccentColor(context)), + 'End : $end', + style: TextStyle( + fontSize: 15, + color: + getVisibleColorOnAccentColor( + context)), ), ], ), ), Padding( - padding: const EdgeInsets.only(bottom: 5), + padding: const EdgeInsets.only( + bottom: 5), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( children: [ Text( 'Number of members in group: ' - '${presentNum}', - style: TextStyle(color: getVisibleColorOnAccentColor(context)), + '$presentNum', + style: TextStyle( + color: + getVisibleColorOnAccentColor( + context)), ) ], ), @@ -194,14 +250,18 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie ), ), Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment.spaceAround, children: [ Column( children: [ Text( 'Max Number of members: ' - '${max}', - style: TextStyle(color: getVisibleColorOnAccentColor(context)), + '$max', + style: TextStyle( + color: + getVisibleColorOnAccentColor( + context)), ) ], ), @@ -214,11 +274,17 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie ), Container( margin: EdgeInsets.only(top: 60), - height: MediaQuery.of(context).size.height * 0.7, + height: MediaQuery.of(context).size.height * + 0.7, child: StreamBuilder( - stream: Firestore.instance.collection('group').document(widget.docId).collection('users').snapshots(), + stream: FirebaseFirestore.instance + .collection('group') + .doc(widget.docId) + .collection('users') + .snapshots(), builder: (ctx, futureSnapshot) { - if (futureSnapshot.connectionState == ConnectionState.waiting) { + if (futureSnapshot.connectionState == + ConnectionState.waiting) { return Column( children: [ CircularProgressIndicator(), @@ -226,64 +292,126 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie ); } return ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemCount: futureSnapshot.data.documents.length, + physics: + NeverScrollableScrollPhysics(), + itemCount: + futureSnapshot.data.docs.length, itemBuilder: (ctx, index) { return Container( - margin: EdgeInsets.symmetric(vertical: 2, horizontal: 10), + margin: EdgeInsets.symmetric( + vertical: 2, + horizontal: 10), width: double.infinity, child: Card( elevation: 4, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Padding( - padding: const EdgeInsets.all(8.0), - child: Text(futureSnapshot.data.documents[index].data['name']), + padding: + const EdgeInsets + .all(8.0), + child: Text( + futureSnapshot.data + .docs[index] + .data()[ + 'name']), ), Padding( - padding: const EdgeInsets.all(8.0), - child: Text(futureSnapshot.data.documents[index].data['hostel']), + padding: + const EdgeInsets + .all(8.0), + child: Text( + futureSnapshot.data + .docs[index] + .data()[ + 'hostel']), ), Padding( - padding: const EdgeInsets.all(8.0), + padding: + const EdgeInsets + .all(8.0), child: IconButton( - onPressed: () async { + onPressed: + () async { try { - if (Platform.isIOS) { - await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data.documents[index].data['mobilenum'].toString()}')).then((result) { - final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, - content: Text( + if (Platform + .isIOS) { + await Clipboard.setData(ClipboardData( + text: + '${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}')) + .then( + (result) { + final snackBar = + SnackBar( + backgroundColor: + Theme.of(context) + .primaryColor, + content: + Text( 'Copied to Clipboard', - style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle( + color: + getVisibleColorOnPrimaryColor(context)), ), - duration: Duration(seconds: 1), + duration: Duration( + seconds: + 1), ); - ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); - ScaffoldMessenger.of(ctx).showSnackBar(snackBar); + ScaffoldMessenger.of( + ctx) + .hideCurrentSnackBar(); + ScaffoldMessenger.of( + ctx) + .showSnackBar( + snackBar); }); } else { - await launch('tel://${futureSnapshot.data.documents[index].data['mobilenum'].toString()}'); + await launch( + 'tel://${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}'); } } catch (e) { - await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data.documents[index].data['mobilenum'].toString()}')).then((result) { - final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, - content: Text( + await Clipboard.setData( + ClipboardData( + text: + '${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}')) + .then( + (result) { + final snackBar = + SnackBar( + backgroundColor: + Theme.of(context) + .primaryColor, + content: + Text( 'Copied to Clipboard', - style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle( + color: + getVisibleColorOnPrimaryColor(context)), ), - duration: Duration(seconds: 1), + duration: Duration( + seconds: + 1), ); - ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); - ScaffoldMessenger.of(ctx).showSnackBar(snackBar); + ScaffoldMessenger + .of(ctx) + .hideCurrentSnackBar(); + ScaffoldMessenger + .of( + ctx) + .showSnackBar( + snackBar); }); } }, icon: Icon( Icons.phone, - color: Theme.of(context).accentColor, + color: Theme.of( + context) + .colorScheme + .secondary, )), ), ], @@ -300,14 +428,19 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie ), bottomNavigationBar: TextButton( style: TextButton.styleFrom( - textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context)), + textStyle: TextStyle( + color: + getVisibleColorOnPrimaryColor(context)), padding: EdgeInsets.all(20), ), onPressed: () async { try { if (GroupDetails.inGroup) { - await Navigator.push(context, MaterialPageRoute(builder: (context) => GroupPage())); + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => GroupPage())); } else if (full) { null; } else if (privacy == 'true' && !full) { @@ -318,24 +451,46 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie context: context, builder: (BuildContext ctx) { return AlertDialog( - title: Text('Request To Join Group'), - content: Text('Are you sure you want to request to join this group?'), + title: + Text('Request To Join Group'), + content: Text( + 'Are you sure you want to request to join this group?'), actions: [ TextButton( - child: Text('Request', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Request', + style: TextStyle( + color: + Theme.of(context) + .colorScheme + .secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); + pr = ProgressDialog(context, + type: ProgressDialogType + .Normal, + isDismissible: false, + showLogs: false); pr.style( message: 'Requesting...', - backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle(color: Theme.of(context).accentColor), + backgroundColor: + Theme.of(context) + .backgroundColor, + messageTextStyle: + TextStyle( + color: Theme.of( + context) + .colorScheme + .secondary), ); await pr.show(); - await Future.delayed(Duration(seconds: 1)); + await Future.delayed( + Duration(seconds: 1)); try { - await _notifServices.createRequest(widget.docId); - await Navigator.of(context).pop(); + await _notifServices + .createRequest( + widget.docId); + Navigator.of(context) + .pop(); await pr.hide(); } catch (e) { await pr.hide(); @@ -344,7 +499,12 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie }, ), TextButton( - child: Text('Cancel', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Cancel', + style: TextStyle( + color: + Theme.of(context) + .colorScheme + .secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -358,24 +518,44 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie builder: (BuildContext ctx) { return AlertDialog( title: Text('Join Group'), - content: Text('Are you sure you want to join this group?'), + content: Text( + 'Are you sure you want to join this group?'), actions: [ TextButton( - child: Text('Join', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Join', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); + pr = ProgressDialog(context, + type: ProgressDialogType + .Normal, + isDismissible: false, + showLogs: false); pr.style( message: 'Joining Group...', - backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle(color: Theme.of(context).accentColor), + backgroundColor: + Theme.of(context) + .backgroundColor, + messageTextStyle: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ); await pr.show(); - await Future.delayed(Duration(seconds: 1)); + await Future.delayed( + Duration(seconds: 1)); try { - await _request.joinGroup(widget.docId); + await _request + .joinGroup(widget.docId); GroupDetails.inGroup = true; - await _notifServices.groupJoin(usersnapshot.data['name'], widget.docId); + await _notifServices + .groupJoin( + usersnapshot + .data()['name'], + widget.docId); await pr.hide(); } catch (e) { await pr.hide(); @@ -395,7 +575,11 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie }, ), TextButton( - child: Text('Cancel', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Cancel', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -412,27 +596,46 @@ class _GroupDetailsState extends State with AutomaticKeepAliveClie ? GroupDetails.inGroup ? Text( 'My Group Page', // You are in a group and viewing a private group - style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + fontSize: 20, + color: getVisibleColorOnAccentColor( + context)), ) : full - ? Text('Group is full', style: TextStyle(fontSize: 20)) + ? Text('Group is full', + style: TextStyle(fontSize: 20)) : requestedToJoin ? Text( 'Requested', // You are not in any group and requested to join - style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + fontSize: 20, + color: + getVisibleColorOnAccentColor( + context)), ) : Text( 'Request to Join', // fresh visit to private group (and user is not in any group) - style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + fontSize: 20, + color: + getVisibleColorOnAccentColor( + context)), ) : GroupDetails.inGroup ? Text( 'My Group Page', // visiting a group page - style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), + style: TextStyle( + fontSize: 20, + color: getVisibleColorOnAccentColor( + context)), ) : full - ? Text('Group is full', style: TextStyle(fontSize: 20)) - : Text('Join Now', style: TextStyle(fontSize: 20)), // Visiting a public group page and not in any group + ? Text('Group is full', + style: TextStyle(fontSize: 20)) + : Text('Join Now', + style: TextStyle( + fontSize: + 20)), // Visiting a public group page and not in any group ), )); } else { diff --git a/lib/screens/groupscreen/editgroup.dart b/lib/screens/groupscreen/editgroup.dart index cf437f3..ce22384 100644 --- a/lib/screens/groupscreen/editgroup.dart +++ b/lib/screens/groupscreen/editgroup.dart @@ -35,14 +35,24 @@ class _EditGroupState extends State { void _updateGroup() async { try { - await _databaseService.updateGroup(groupUID, _selectedStartDate, _selectedStartTime, _selectedEndDate, _selectedEndTime, privacy, _maxPoolers); + await _databaseService.updateGroup( + groupUID, + _selectedStartDate, + _selectedStartTime, + _selectedEndDate, + _selectedEndTime, + privacy, + _maxPoolers); } catch (e) { print(e.toString()); } } void _submitData() { - if (_selectedStartDate == null || _selectedStartTime == null || _selectedEndDate == null || _selectedEndTime == null) { + if (_selectedStartDate == null || + _selectedStartTime == null || + _selectedEndDate == null || + _selectedEndTime == null) { return; //return stops function execution and thus nothing is called or returned } setState(() { @@ -52,7 +62,12 @@ class _EditGroupState extends State { } void _startDatePicker() { - showDatePicker(context: context, initialDate: _selectedStartDate, firstDate: DateTime.parse(_selectedStartDate.toString()), lastDate: DateTime.now().add(Duration(days: 30))).then((pickedDate) { + showDatePicker( + context: context, + initialDate: _selectedStartDate, + firstDate: DateTime.parse(_selectedStartDate.toString()), + lastDate: DateTime.now().add(Duration(days: 30))) + .then((pickedDate) { if (pickedDate == null) { return; } @@ -64,7 +79,12 @@ class _EditGroupState extends State { } void _endDatePicker() { - showDatePicker(context: context, initialDate: _selectedEndDate, firstDate: DateTime.parse(_selectedEndDate.toString()), lastDate: DateTime.now().add(Duration(days: 30))).then((pickedDate) { + showDatePicker( + context: context, + initialDate: _selectedEndDate, + firstDate: DateTime.parse(_selectedEndDate.toString()), + lastDate: DateTime.now().add(Duration(days: 30))) + .then((pickedDate) { if (pickedDate == null) { return; } @@ -126,25 +146,30 @@ class _EditGroupState extends State { ); } - Widget buildContainer(String point, DateTime date, TimeOfDay time, Function DatePicker, Function TimePicker) { + Widget buildContainer(String point, DateTime date, TimeOfDay time, + Function DatePicker, Function TimePicker) { return Container( margin: EdgeInsets.only(top: 20, left: 30, right: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Text(date == null ? '$point Date' : '${DateFormat.yMd().format(date)}'), + Text(date == null + ? '$point Date' + : '${DateFormat.yMd().format(date)}'), IconButton( icon: Icon( Icons.calendar_today, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), onPressed: () => DatePicker(), ), - Text(time == null ? '$point Time' : '${time.toString().substring(10, 15)}'), + Text(time == null + ? '$point Time' + : '${time.toString().substring(10, 15)}'), IconButton( icon: Icon( Icons.schedule, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), onPressed: () => TimePicker(), ), @@ -155,16 +180,22 @@ class _EditGroupState extends State { @override void initState() { - Firestore.instance.collection('group').document(groupUID).get().then((value) { + FirebaseFirestore.instance + .collection('group') + .doc(groupUID) + .get() + .then((value) { setState(() { - startTS = value.data['start']; - endTS = value.data['end']; - tempPrivacy = value.data['privacy']; + startTS = value.data()['start']; + endTS = value.data()['end']; + tempPrivacy = value.data()['privacy']; _selectedStartDate = startTS.toDate(); _selectedEndDate = endTS.toDate(); - _selectedStartTime = TimeOfDay(hour: _selectedStartDate.hour, minute: _selectedStartDate.minute); - _selectedEndTime = TimeOfDay(hour: _selectedEndDate.hour, minute: _selectedEndDate.minute); - _maxPoolers = value.data['maxpoolers']; + _selectedStartTime = TimeOfDay( + hour: _selectedStartDate.hour, minute: _selectedStartDate.minute); + _selectedEndTime = TimeOfDay( + hour: _selectedEndDate.hour, minute: _selectedEndDate.minute); + _maxPoolers = value.data()['maxpoolers']; }); if (tempPrivacy == 'true') { privacy = true; @@ -194,14 +225,21 @@ class _EditGroupState extends State { child: Column( children: [ buildLabel('Starting'), - buildContainer('Start', _selectedStartDate, _selectedStartTime, _startDatePicker, _startTimePicker), + buildContainer( + 'Start', + _selectedStartDate, + _selectedStartTime, + _startDatePicker, + _startTimePicker), buildLabel('Ending'), - buildContainer('End', _selectedEndDate, _selectedEndTime, _endDatePicker, _endTimePicker), + buildContainer('End', _selectedEndDate, _selectedEndTime, + _endDatePicker, _endTimePicker), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.only(top: 30.0, left: 40.0), + padding: + const EdgeInsets.only(top: 30.0, left: 40.0), child: Text('Max No. of poolers:', style: TextStyle( fontSize: 20.0, @@ -222,7 +260,9 @@ class _EditGroupState extends State { child: Text( dropDownIntItem.toString(), style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, ), ), ); @@ -252,8 +292,10 @@ class _EditGroupState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Checkbox( - checkColor: getVisibleColorOnAccentColor(context), - activeColor: Theme.of(context).accentColor, + checkColor: + getVisibleColorOnAccentColor(context), + activeColor: + Theme.of(context).colorScheme.secondary, value: privacy, onChanged: (bool value) { setState(() { @@ -277,27 +319,44 @@ class _EditGroupState extends State { ), child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).accentColor, - textStyle: TextStyle(color: getVisibleColorOnAccentColor(context)), + primary: Theme.of(context).colorScheme.secondary, + textStyle: TextStyle( + color: getVisibleColorOnAccentColor(context)), ), onPressed: () { - var starting = DateTime(_selectedStartDate.year, _selectedStartDate.month, _selectedStartDate.day, _selectedStartTime.hour, _selectedStartTime.minute); - var ending = DateTime(_selectedEndDate.year, _selectedEndDate.month, _selectedEndDate.day, _selectedEndTime.hour, _selectedEndTime.minute); + var starting = DateTime( + _selectedStartDate.year, + _selectedStartDate.month, + _selectedStartDate.day, + _selectedStartTime.hour, + _selectedStartTime.minute); + var ending = DateTime( + _selectedEndDate.year, + _selectedEndDate.month, + _selectedEndDate.day, + _selectedEndTime.hour, + _selectedEndTime.minute); if (starting.compareTo(ending) < 0) { _submitData(); } else { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( + ScaffoldMessenger.of(context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar( backgroundColor: Theme.of(context).primaryColor, duration: Duration(seconds: 2), content: Text( 'INVALID : Start Time > End Time', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ), )); } }, - child: Text('Update Trip', style: TextStyle(fontSize: 18)), + child: Text('Update Trip', + style: TextStyle(fontSize: 18)), ), ), ], diff --git a/lib/screens/groupscreen/group.dart b/lib/screens/groupscreen/group.dart index bfc3cc1..743efd5 100644 --- a/lib/screens/groupscreen/group.dart +++ b/lib/screens/groupscreen/group.dart @@ -21,7 +21,8 @@ class GroupPage extends StatefulWidget { _GroupPageState createState() => _GroupPageState(); } -class _GroupPageState extends State with AutomaticKeepAliveClientMixin { +class _GroupPageState extends State + with AutomaticKeepAliveClientMixin { final RequestService _request = RequestService(); final NotifServices _notifServices = NotifServices(); final GlobalKey scaffoldKey = GlobalKey(); @@ -44,8 +45,12 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi double userRating; Future getMembers(String docid) async { - var qp = await Firestore.instance.collection('group').document(docid).collection('users').getDocuments(); - return qp.documents; + var qp = await FirebaseFirestore.instance + .collection('group') + .doc(docid) + .collection('users') + .get(); + return qp.docs; } bool buttonEnabled = true; @@ -56,29 +61,38 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi @override Widget build(BuildContext context) { super.build(context); - final currentuser = Provider.of(context); + final currentuser = Provider.of(context); return StreamBuilder( - stream: Firestore.instance.collection('userdetails').document(currentuser.uid).snapshots(), + stream: FirebaseFirestore.instance + .collection('userdetails') + .doc(currentuser.uid) + .snapshots(), builder: (context, usersnapshot) { if (usersnapshot.connectionState == ConnectionState.active) { if (buttonEnabled == true) { - groupUID = usersnapshot.data['currentGroup']; + groupUID = usersnapshot.data()['currentGroup']; } - if (usersnapshot.data['currentGroup'] == null) { + if (usersnapshot.data()['currentGroup'] == null) { Navigator.pop(context); } return StreamBuilder( - stream: Firestore.instance.collection('group').document(groupUID).snapshots(), + stream: FirebaseFirestore.instance + .collection('group') + .doc(groupUID) + .snapshots(), builder: (context, groupsnapshot) { if (groupsnapshot.connectionState == ConnectionState.active) { if (buttonEnabled == true) { - destination = groupsnapshot.data['destination']; - start = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data['start'].toDate()); - end = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data['end'].toDate()); - grpOwner = groupsnapshot.data['owner']; - presentNum = groupsnapshot.data['numberOfMembers'].toString(); - endTimeStamp = groupsnapshot.data['end']; - maxPoolers = groupsnapshot.data['maxpoolers']; + destination = groupsnapshot.data()['destination']; + start = DateFormat('dd.MM.yyyy - kk:mm a') + .format(groupsnapshot.data()['start'].toDate()); + end = DateFormat('dd.MM.yyyy - kk:mm a') + .format(groupsnapshot.data()['end'].toDate()); + grpOwner = groupsnapshot.data()['owner']; + presentNum = + groupsnapshot.data()['numberOfMembers'].toString(); + endTimeStamp = groupsnapshot.data()['end']; + maxPoolers = groupsnapshot.data()['maxpoolers']; loading = false; if (endTimeStamp.compareTo(Timestamp.now()) < 0) { timestampFlag = true; @@ -93,51 +107,107 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi buttonEnabled ? timestampFlag ? TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), - icon: Icon(FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom( + textStyle: TextStyle( + color: + getVisibleColorOnPrimaryColor( + context))), + icon: Icon( + FontAwesomeIcons.signOutAlt), onPressed: () async { try { await showDialog( context: context, - builder: (BuildContext ctx) { + builder: + (BuildContext ctx) { return AlertDialog( title: Text('End Trip'), - content: Text('Are you sure you want to end this trip?'), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), + content: Text( + 'Are you sure you want to end this trip?'), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 20.0)), actions: [ TextButton( - child: Text('End', style: TextStyle(color: Theme.of(context).accentColor)), - onPressed: () async { + child: Text('End', + style: TextStyle( + color: Theme.of( + context) + .colorScheme + .secondary)), + onPressed: + () async { ProgressDialog pr; - pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); + pr = ProgressDialog( + context, + type: ProgressDialogType + .Normal, + isDismissible: + false, + showLogs: + false); pr.style( - message: 'Ending Trip...', - backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle( - color: getVisibleTextColorOnScaffold(context), + message: + 'Ending Trip...', + backgroundColor: + Theme.of( + context) + .backgroundColor, + messageTextStyle: + TextStyle( + color: getVisibleTextColorOnScaffold( + context), ), ); await pr.show(); - await Future.delayed(Duration(seconds: 1)); + await Future.delayed( + Duration( + seconds: + 1)); try { - buttonEnabled = false; - await _request.exitGroup(); - Navigator.pop(context); + buttonEnabled = + false; + await _request + .exitGroup(); + Navigator.pop( + context); await pr.hide(); } catch (e) { await pr.hide(); - print(e.toString()); - String errStr = e.message ?? e.toString(); - final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + print(e + .toString()); + String errStr = + e.message ?? + e.toString(); + final snackBar = SnackBar( + content: Text( + errStr), + duration: Duration( + seconds: + 3)); + ScaffoldMessenger.of( + context) + .showSnackBar( + snackBar); } - Navigator.pop(context); + Navigator.pop( + context); }, ), TextButton( - child: Text('Cancel', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text( + 'Cancel', + style: TextStyle( + color: Theme.of( + context) + .colorScheme + .secondary)), onPressed: () { - Navigator.of(context).pop(); + Navigator.of( + context) + .pop(); }, ), ], @@ -150,52 +220,113 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi label: Text('End Trip'), ) : TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), - icon: Icon(FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom( + textStyle: TextStyle( + color: + getVisibleColorOnPrimaryColor( + context))), + icon: Icon( + FontAwesomeIcons.signOutAlt), onPressed: () async { try { await showDialog( context: context, - builder: (BuildContext ctx) { + builder: + (BuildContext ctx) { return AlertDialog( - title: Text('Leave Group'), - content: Text('Are you sure you want to leave this group?'), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), + title: + Text('Leave Group'), + content: Text( + 'Are you sure you want to leave this group?'), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 20.0)), actions: [ TextButton( - child: Text('Leave', style: TextStyle(color: Theme.of(context).accentColor)), - onPressed: () async { + child: Text('Leave', + style: TextStyle( + color: Theme.of( + context) + .colorScheme + .secondary)), + onPressed: + () async { ProgressDialog pr; - pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); + pr = ProgressDialog( + context, + type: ProgressDialogType + .Normal, + isDismissible: + false, + showLogs: + false); pr.style( - message: 'Leaving Group...', - backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle( - color: getVisibleTextColorOnScaffold(context), + message: + 'Leaving Group...', + backgroundColor: + Theme.of( + context) + .backgroundColor, + messageTextStyle: + TextStyle( + color: getVisibleTextColorOnScaffold( + context), ), ); await pr.show(); - await Future.delayed(Duration(seconds: 1)); + await Future.delayed( + Duration( + seconds: + 1)); try { - buttonEnabled = false; - await _notifServices.leftGroup(usersnapshot.data['name'], groupUID); - await _request.exitGroup(); - Navigator.pop(context); + buttonEnabled = + false; + await _notifServices.leftGroup( + usersnapshot + .data()[ + 'name'], + groupUID); + await _request + .exitGroup(); + Navigator.pop( + context); await pr.hide(); } catch (e) { await pr.hide(); - print(e.toString()); - String errStr = e.message ?? e.toString(); - final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + print(e + .toString()); + String errStr = + e.message ?? + e.toString(); + final snackBar = SnackBar( + content: Text( + errStr), + duration: Duration( + seconds: + 3)); + ScaffoldMessenger.of( + context) + .showSnackBar( + snackBar); } - Navigator.pop(context); + Navigator.pop( + context); }, ), TextButton( - child: Text('Cancel', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text( + 'Cancel', + style: TextStyle( + color: Theme.of( + context) + .colorScheme + .secondary)), onPressed: () { - Navigator.of(context).pop(); + Navigator.of( + context) + .pop(); }, ), ], @@ -209,14 +340,24 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi ) : timestampFlag ? TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), - icon: Icon(FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom( + textStyle: TextStyle( + color: + getVisibleColorOnPrimaryColor( + context))), + icon: Icon( + FontAwesomeIcons.signOutAlt), onPressed: null, label: Text('End Trip'), ) : TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), - icon: Icon(FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom( + textStyle: TextStyle( + color: + getVisibleColorOnPrimaryColor( + context))), + icon: Icon( + FontAwesomeIcons.signOutAlt), onPressed: null, label: Text('Leave Group'), ) @@ -228,7 +369,8 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Flexible( fit: FlexFit.tight, @@ -238,21 +380,32 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi left: 20, top: 20, ), - child: destination == 'New Delhi Railway Station' || destination == 'Hazrat Nizamuddin Railway Station' + child: destination == + 'New Delhi Railway Station' || + destination == + 'Hazrat Nizamuddin Railway Station' ? Icon( Icons.train, - color: getVisibleIconColorOnScaffold(context), + color: + getVisibleIconColorOnScaffold( + context), size: 30, ) - : destination == 'Indira Gandhi International Airport' + : destination == + 'Indira Gandhi International Airport' ? Icon( - Icons.airplanemode_active, - color: getVisibleIconColorOnScaffold(context), + Icons + .airplanemode_active, + color: + getVisibleIconColorOnScaffold( + context), size: 30, ) : Icon( Icons.directions_bus, - color: getVisibleIconColorOnScaffold(context), + color: + getVisibleIconColorOnScaffold( + context), size: 30, )), ), @@ -260,7 +413,8 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi fit: FlexFit.tight, flex: 4, child: Padding( - padding: const EdgeInsets.only(top: 10.0), + padding: const EdgeInsets.only( + top: 10.0), child: Text( destination, style: TextStyle( @@ -279,22 +433,34 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi top: 10, ), child: Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, children: [ - Text('Press here to edit the details: '), + Text( + 'Press here to edit the details: '), TextButton.icon( onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => EditGroup(groupUID: groupUID))); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + EditGroup( + groupUID: + groupUID))); }, icon: Icon( FontAwesomeIcons.pen, size: 16.0, - color: getVisibleTextColorOnScaffold(context), + color: + getVisibleTextColorOnScaffold( + context), ), label: Text( 'Edit', style: TextStyle( - color: getVisibleTextColorOnScaffold(context), + color: + getVisibleTextColorOnScaffold( + context), ), )), ], @@ -305,11 +471,15 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi top: 10, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( '*Contact group admin to edit details.', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ), ], ), @@ -320,7 +490,8 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi top: 10, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( 'Start : $start', @@ -336,7 +507,8 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi bottom: 5, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( 'End: $end', @@ -352,10 +524,11 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi bottom: 5, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( - 'Number of members in group: ${presentNum}', + 'Number of members in group: $presentNum', style: TextStyle( fontSize: 15, ), @@ -368,10 +541,11 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi bottom: 5, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( - 'Max number of poolers: ${maxPoolers}', + 'Max number of poolers: $maxPoolers', style: TextStyle( fontSize: 15, ), @@ -381,20 +555,33 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi ), Container( child: StreamBuilder( - stream: Firestore.instance.collection('group').document(groupUID).collection('users').snapshots(), + stream: FirebaseFirestore.instance + .collection('group') + .doc(groupUID) + .collection('users') + .snapshots(), builder: (_, snapshots) { if (!snapshots.hasData) { return Center( - child: CircularProgressIndicator(), + child: + CircularProgressIndicator(), ); } return ListView.builder( shrinkWrap: true, - itemCount: snapshots.data == null ? 0 : snapshots.data.documents.length, + itemCount: snapshots.data == null + ? 0 + : snapshots.data.docs.length, itemBuilder: (ctx, index) { - var cancelledRides = snapshots.data.documents[index].data['cancelledrides']; - var totalRides = snapshots.data.documents[index].data['totalrides']; - userRating = 5 - (0.2 * cancelledRides) + (0.35 * totalRides); + var cancelledRides = snapshots + .data.docs[index] + .data()['cancelledrides']; + var totalRides = snapshots + .data.docs[index] + .data()['totalrides']; + userRating = 5 - + (0.2 * cancelledRides) + + (0.35 * totalRides); if (userRating < 0) { userRating = 0; } @@ -402,81 +589,154 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi userRating = 5; } return Card( - color: Theme.of(context).scaffoldBackgroundColor, + color: Theme.of(context) + .scaffoldBackgroundColor, child: ListTile( - title: Text(snapshots.data.documents[index].data['name']), + title: Text(snapshots + .data.docs[index] + .data()['name']), subtitle: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - Text('Hostel: ${snapshots.data.documents[index].data['hostel']}'), + Text( + 'Hostel: ${snapshots.data.docs[index].data()['hostel']}'), GestureDetector( onTap: () async { try { - if (Platform.isIOS) { - await Clipboard.setData(ClipboardData(text: '${snapshots.data.documents[index].data['mobilenum']}')).then((result) { - final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, - content: Text( + if (Platform + .isIOS) { + await Clipboard.setData( + ClipboardData( + text: + '${snapshots.data.docs[index].data()['mobilenum']}')) + .then( + (result) { + final snackBar = + SnackBar( + backgroundColor: + Theme.of(context) + .primaryColor, + content: + Text( 'Copied to Clipboard', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ), - duration: Duration(seconds: 1), + duration: Duration( + seconds: + 1), ); - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + ScaffoldMessenger.of( + context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of( + context) + .showSnackBar( + snackBar); }); } else { - await launch('tel://${snapshots.data.documents[index].data['mobilenum']}'); + await launch( + 'tel://${snapshots.data.docs[index].data()['mobilenum']}'); } } catch (e) { - await Clipboard.setData(ClipboardData(text: '${snapshots.data.documents[index].data['mobilenum']}')).then((result) { - final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, + await Clipboard.setData( + ClipboardData( + text: + '${snapshots.data.docs[index].data()['mobilenum']}')) + .then( + (result) { + final snackBar = + SnackBar( + backgroundColor: + Theme.of( + context) + .primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ), - duration: Duration(seconds: 1), + duration: + Duration( + seconds: + 1), ); - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + ScaffoldMessenger.of( + context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of( + context) + .showSnackBar( + snackBar); }); } }, - child: Text('Mobile Number: ${snapshots.data.documents[index].data['mobilenum']}')), + child: Text( + 'Mobile Number: ${snapshots.data.docs[index].data()['mobilenum']}')), Row( children: [ Text('User Rating:'), Row( - children: [], + children: < + Widget>[], ), - showRating(userRating), + showRating( + userRating), ], ) ], ), - trailing: grpOwner == snapshots.data.documents[index].documentID + trailing: grpOwner == + snapshots.data + .docs[index].id ? FaIcon( - FontAwesomeIcons.crown, - color: getVisibleIconColorOnScaffold(context), + FontAwesomeIcons + .crown, + color: + getVisibleIconColorOnScaffold( + context), ) - : grpOwner == currentuser.uid && !timestampFlag + : grpOwner == + currentuser + .uid && + !timestampFlag ? IconButton( - icon: Icon(Icons.exit_to_app), - color: getVisibleIconColorOnScaffold(context), - tooltip: 'Kick User', - onPressed: () async { + icon: Icon(Icons + .exit_to_app), + color: + getVisibleIconColorOnScaffold( + context), + tooltip: + 'Kick User', + onPressed: + () async { await showDialog( - context: context, - builder: (BuildContext ctx) { + context: + context, + builder: + (BuildContext + ctx) { return AlertDialog( - title: Text('Kick User'), - content: Text('Are you sure you want to kick this user?'), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), - actions: [ + title: Text( + 'Kick User'), + content: + Text('Are you sure you want to kick this user?'), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(20.0)), + actions: < + Widget>[ TextButton( - child: Text('Kick', style: TextStyle(color: Theme.of(context).accentColor)), - onPressed: () async { + child: + Text('Kick', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), + onPressed: + () async { Navigator.pop(context); ProgressDialog pr; pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); @@ -489,7 +749,7 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi ); await pr.show(); try { - await _request.kickUser(groupUID, snapshots.data.documents[index].documentID); + await _request.kickUser(groupUID, snapshots.data.docs[index].id); await pr.hide(); } catch (e) { await pr.hide(); @@ -498,8 +758,10 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi }, ), TextButton( - child: Text('Cancel', style: TextStyle(color: Theme.of(context).accentColor)), - onPressed: () { + child: + Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), + onPressed: + () { Navigator.of(context).pop(); }, ), @@ -524,7 +786,11 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi ), floatingActionButton: FloatingActionButton( onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => ChatScreen(groupUID))); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + ChatScreen(groupUID))); }, child: Stack( alignment: Alignment(-10, -10), @@ -539,7 +805,8 @@ class _GroupPageState extends State with AutomaticKeepAliveClientMixi ), ); } else { - return Container(child: Center(child: CircularProgressIndicator())); + return Container( + child: Center(child: CircularProgressIndicator())); } }); } else { diff --git a/lib/screens/notifications/services/database.dart b/lib/screens/notifications/services/database.dart index 43b9e0a..6d3626d 100644 --- a/lib/screens/notifications/services/database.dart +++ b/lib/screens/notifications/services/database.dart @@ -3,24 +3,27 @@ import 'package:firebase_auth/firebase_auth.dart'; class NotificationDatabase { final _auth = FirebaseAuth.instance; - final CollectionReference groupdetails = Firestore.instance.collection('group'); - final CollectionReference userDetails = Firestore.instance.collection('userdetails'); - final CollectionReference chatLists = Firestore.instance.collection('chatroom'); + final CollectionReference> groupdetails = + FirebaseFirestore.instance.collection('group'); + final CollectionReference> userDetails = + FirebaseFirestore.instance.collection('userdetails'); + final CollectionReference> chatLists = + FirebaseFirestore.instance.collection('chatroom'); //Request created to join a group Future createRequest(String groupId) async { - var user = await _auth.currentUser(); + var user = _auth.currentUser; var name; var admin; - await userDetails.document(user.uid).get().then((value) { - name = value.data['name']; + await userDetails.doc(user.uid).get().then((value) { + name = value.data()['name']; }); - await groupdetails.document(groupId).get().then((value) { - admin = value.data['owner']; + await groupdetails.doc(groupId).get().then((value) { + admin = value.data()['owner']; }); if (admin != null) { - await userDetails.document(admin).collection('Notifications').add({ + await userDetails.doc(admin).collection('Notifications').add({ 'from': user.uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -28,7 +31,7 @@ class NotificationDatabase { 'response': null, 'groupId': groupId, }); - await userDetails.document(user.uid).updateData({ + await userDetails.doc(user.uid).update({ 'currentGroupJoinRequests': FieldValue.arrayUnion([groupId]) }); } @@ -37,18 +40,18 @@ class NotificationDatabase { //Creating a notification when a user joins the group (non-private groups) Future joined(String name, String groupId) async { var allUsers; - final user = await _auth.currentUser(); + final user = _auth.currentUser; - await groupdetails.document(groupId).get().then((value) { - allUsers = value.data['users']; + await groupdetails.doc(groupId).get().then((value) { + allUsers = value.data()['users']; }); - await userDetails.document(user.uid).updateData({ + await userDetails.doc(user.uid).update({ 'currentGroupJoinRequests': null, }); for (var i = 0; i < allUsers.length; i++) { if (allUsers[i] != user.uid) { - await userDetails.document(allUsers[i]).collection('Notifications').add({ + await userDetails.doc(allUsers[i]).collection('Notifications').add({ 'from': user.uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -62,74 +65,87 @@ class NotificationDatabase { //Updating response, adding user to the group, adding user to chatroom Future response(bool response, String notifId) async { - var user = await _auth.currentUser(); + var user = _auth.currentUser; var listuid; var uid; var name; var nameo; - await userDetails.document(user.uid).collection('Notifications').document(notifId).updateData({ + await userDetails + .doc(user.uid) + .collection('Notifications') + .doc(notifId) + .update({ 'response': response, }); if (response == true) { - await userDetails.document(user.uid).collection('Notifications').document(notifId).get().then((value) { - listuid = value.data['groupId']; - uid = value.data['from']; + await userDetails + .doc(user.uid) + .collection('Notifications') + .doc(notifId) + .get() + .then((value) { + listuid = value.data()['groupId']; + uid = value.data()['from']; }); var presentNum; var maxPoolers; - await userDetails.document(uid).updateData({ + await userDetails.doc(uid).update({ // 'previous_groups': FieldValue.arrayUnion([listuid]), 'currentGroup': listuid, 'currentGroupJoinRequests': null, }); - await groupdetails.document(listuid).get().then((value) { - presentNum = value.data['numberOfMembers']; - maxPoolers = value.data['maxpoolers']; + await groupdetails.doc(listuid).get().then((value) { + presentNum = value.data()['numberOfMembers']; + maxPoolers = value.data()['maxpoolers']; }); if (presentNum == maxPoolers) { - await groupdetails.document(listuid).updateData({ + await groupdetails.doc(listuid).update({ 'users': FieldValue.arrayUnion([uid.toString()]), 'numberOfMembers': presentNum + 1, 'maxpoolers': maxPoolers + 1, }); } else { - await groupdetails.document(listuid).updateData({ + await groupdetails.doc(listuid).update({ 'users': FieldValue.arrayUnion([uid.toString()]), 'numberOfMembers': presentNum + 1, }); } - var request = groupdetails.document(listuid).collection('users'); - await Firestore.instance.collection('userdetails').document(uid).get().then((value) async { + var request = groupdetails.doc(listuid).collection('users'); + await FirebaseFirestore.instance + .collection('userdetails') + .doc(uid) + .get() + .then((value) async { if (value.exists) { - await request.document(uid).setData({ - 'name': value.data['name'], - 'hostel': value.data['hostel'], - 'sex': value.data['sex'], - 'mobilenum': value.data['mobileNumber'], - 'totalrides': value.data['totalRides'], - 'actualrating': value.data['actualRating'], - 'cancelledrides': value.data['cancelledRides'], - 'numberofratings': value.data['numberOfRatings'], + await request.doc(uid).set({ + 'name': value.data()['name'], + 'hostel': value.data()['hostel'], + 'sex': value.data()['sex'], + 'mobilenum': value.data()['mobileNumber'], + 'totalrides': value.data()['totalRides'], + 'actualrating': value.data()['actualRating'], + 'cancelledrides': value.data()['cancelledRides'], + 'numberofratings': value.data()['numberOfRatings'], }); - name = value.data['name']; + name = value.data()['name']; } }); var allUsers; - await groupdetails.document(listuid).get().then((value) { - allUsers = value.data['users']; + await groupdetails.doc(listuid).get().then((value) { + allUsers = value.data()['users']; }); - await userDetails.document(user.uid).get().then((value) { - nameo = value.data['name']; + await userDetails.doc(user.uid).get().then((value) { + nameo = value.data()['name']; }); for (var i = 0; i < allUsers.length; i++) { if (allUsers[i] != uid && allUsers[i] != user.uid) { - await userDetails.document(allUsers[i]).collection('Notifications').add({ + await userDetails.doc(allUsers[i]).collection('Notifications').add({ 'from': uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -138,7 +154,7 @@ class NotificationDatabase { 'groupId': listuid, }); } else if (allUsers[i] == uid) { - await userDetails.document(uid).collection('Notifications').add({ + await userDetails.doc(uid).collection('Notifications').add({ 'from': user.uid, 'senderName': nameo, 'createdAt': Timestamp.now(), @@ -149,21 +165,26 @@ class NotificationDatabase { } } - await chatLists.document(listuid).updateData({ + await chatLists.doc(listuid).update({ 'users': FieldValue.arrayUnion([uid.toString()]), }); } else if (response == false) { var name; - await userDetails.document(user.uid).get().then((value) { - name = value.data['name']; + await userDetails.doc(user.uid).get().then((value) { + name = value.data()['name']; }); - await userDetails.document(user.uid).collection('Notifications').document(notifId).get().then((value) { - listuid = value.data['groupId']; - uid = value.data['from']; + await userDetails + .doc(user.uid) + .collection('Notifications') + .doc(notifId) + .get() + .then((value) { + listuid = value.data()['groupId']; + uid = value.data()['from']; }); - await userDetails.document(uid).collection('Notifications').add({ + await userDetails.doc(uid).collection('Notifications').add({ 'from': user.uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -176,15 +197,15 @@ class NotificationDatabase { //Creating a notification for all users of a group when a user leaves that group Future left(String name, String groupId) async { - final user = await _auth.currentUser(); + final user = _auth.currentUser; var allUsers; - await groupdetails.document(groupId).get().then((value) { - allUsers = value.data['users']; + await groupdetails.doc(groupId).get().then((value) { + allUsers = value.data()['users']; }); for (var i = 0; i < allUsers.length; i++) { if (user.uid != allUsers[i]) { - await userDetails.document(allUsers[i]).collection('Notifications').add({ + await userDetails.doc(allUsers[i]).collection('Notifications').add({ 'from': user.uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -197,21 +218,27 @@ class NotificationDatabase { } //Deleting a notification - Future remNotif(String notifId, var purpose, var uid, var response) async { - final user = await _auth.currentUser(); + Future remNotif( + String notifId, var purpose, var uid, var response) async { + final user = _auth.currentUser; if (purpose == 'Request to Join' && response == false) { var name; var listuid; - await userDetails.document(user.uid).get().then((value) { - name = value.data['name']; + await userDetails.doc(user.uid).get().then((value) { + name = value.data()['name']; }); - await userDetails.document(user.uid).collection('Notifications').document(notifId).get().then((value) { - listuid = value.data['groupId']; + await userDetails + .doc(user.uid) + .collection('Notifications') + .doc(notifId) + .get() + .then((value) { + listuid = value.data()['groupId']; }); - await userDetails.document(uid).collection('Notifications').add({ + await userDetails.doc(uid).collection('Notifications').add({ 'from': user.uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -220,22 +247,31 @@ class NotificationDatabase { 'groupId': listuid, }); } - await userDetails.document(user.uid).collection('Notifications').document(notifId).delete(); + await userDetails + .doc(user.uid) + .collection('Notifications') + .doc(notifId) + .delete(); } Future removeAllNotif() async { - final user = await _auth.currentUser(); - final notifs = await userDetails.document(user.uid).collection('Notifications').getDocuments(); - for (var i = 0; i < notifs.documents.length; i++) { - if (notifs.documents[i].data['response'] == null && notifs.documents[i].data['purpose'] == 'Request to Join') { + final user = _auth.currentUser; + final notifs = + await userDetails.doc(user.uid).collection('Notifications').get(); + for (var i = 0; i < notifs.docs.length; i++) { + if (notifs.docs[i].data()['response'] == null && + notifs.docs[i].data()['purpose'] == 'Request to Join') { var name; var listuid; - await userDetails.document(user.uid).get().then((value) { - name = value.data['name']; + await userDetails.doc(user.uid).get().then((value) { + name = value.data()['name']; }); - listuid = notifs.documents[i].documentID; - await userDetails.document(notifs.documents[i].data['from']).collection('Notifications').add({ + listuid = notifs.docs[i].id; + await userDetails + .doc(notifs.docs[i].data()['from']) + .collection('Notifications') + .add({ 'from': user.uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -244,7 +280,11 @@ class NotificationDatabase { 'groupId': listuid, }); } - await userDetails.document(user.uid).collection('Notifications').document(notifs.documents[i].documentID).delete(); + await userDetails + .doc(user.uid) + .collection('Notifications') + .doc(notifs.docs[i].id) + .delete(); } } } diff --git a/lib/screens/notifications/widgets/notifslist.dart b/lib/screens/notifications/widgets/notifslist.dart index 0acff8f..2eb753c 100644 --- a/lib/screens/notifications/widgets/notifslist.dart +++ b/lib/screens/notifications/widgets/notifslist.dart @@ -6,7 +6,7 @@ import './notiftile.dart'; import 'package:shareacab/screens/notifications/services/notifservices.dart'; class NotifsList extends StatefulWidget { - static FirebaseUser user; + static User user; @override _NotifsListState createState() => _NotifsListState(); @@ -15,12 +15,19 @@ class NotifsList extends StatefulWidget { class _NotifsListState extends State { final NotifServices _notifServices = NotifServices(); - Future getUserDetails(String uid, String purpose, String notifId, var response) async { + Future getUserDetails( + String uid, String purpose, String notifId, var response) async { var currentGroup; - await Firestore.instance.collection('userdetails').document(uid).get().then((value) { - currentGroup = value.data['currentGroup']; + await FirebaseFirestore.instance + .collection('userdetails') + .doc(uid) + .get() + .then((value) { + currentGroup = value.data()['currentGroup']; }); - if (currentGroup != null && purpose == 'Request to Join' && response == null) { + if (currentGroup != null && + purpose == 'Request to Join' && + response == null) { await _notifServices.removeNotif(notifId, purpose, uid, response); return null; } @@ -29,9 +36,14 @@ class _NotifsListState extends State { @override Widget build(BuildContext context) { - final user = Provider.of(context); + final user = Provider.of(context); return StreamBuilder( - stream: Firestore.instance.collection('userdetails').document(user.uid).collection('Notifications').orderBy('createdAt', descending: true).snapshots(), + stream: FirebaseFirestore.instance + .collection('userdetails') + .doc(user.uid) + .collection('Notifications') + .orderBy('createdAt', descending: true) + .snapshots(), builder: (ctx, futureSnapshot) { if (futureSnapshot.connectionState == ConnectionState.waiting) { return Center( @@ -39,20 +51,23 @@ class _NotifsListState extends State { ); } return ListView.builder( - itemCount: futureSnapshot.data == null ? 0 : futureSnapshot.data.documents.length, + itemCount: + futureSnapshot.data == null ? 0 : futureSnapshot.data.docs.length, itemBuilder: (context, index) { - final docId = futureSnapshot.data.documents[index].documentID; - final fromuid = futureSnapshot.data.documents[index].data['from']; - final name = futureSnapshot.data.documents[index].data['senderName']; - final createdAt = futureSnapshot.data.documents[index].data['createdAt']; - final response = futureSnapshot.data.documents[index].data['response']; - final purpose = futureSnapshot.data.documents[index].data['purpose']; + final docId = futureSnapshot.data.docs[index].id; + final fromuid = futureSnapshot.data.docs[index].data()['from']; + final name = futureSnapshot.data.docs[index].data()['senderName']; + final createdAt = + futureSnapshot.data.docs[index].data()['createdAt']; + final response = futureSnapshot.data.docs[index].data()['response']; + final purpose = futureSnapshot.data.docs[index].data()['purpose']; return FutureBuilder( future: getUserDetails(fromuid, purpose, docId, response), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) {} if (snapshot != null) { - return NotifTile(docId, fromuid, name, createdAt, response, purpose); + return NotifTile( + docId, fromuid, name, createdAt, response, purpose); } return null; }); diff --git a/lib/screens/notifications/widgets/notiftile.dart b/lib/screens/notifications/widgets/notiftile.dart index 3690d50..5b47131 100644 --- a/lib/screens/notifications/widgets/notiftile.dart +++ b/lib/screens/notifications/widgets/notiftile.dart @@ -29,7 +29,7 @@ class _NotifTileState extends State { background: Container( alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 20), - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, child: Icon( Icons.delete, color: Colors.white, @@ -39,11 +39,11 @@ class _NotifTileState extends State { padding: EdgeInsets.symmetric(vertical: 15), decoration: BoxDecoration( border: Border( - bottom: BorderSide(width: 0.15, color: Theme.of(context).accentColor), + bottom: BorderSide(width: 0.15, color: Theme.of(context).colorScheme.secondary), )), child: ListTile( leading: CircleAvatar( - backgroundColor: Theme.of(context).accentColor, + backgroundColor: Theme.of(context).colorScheme.secondary, radius: 40, child: Padding( padding: EdgeInsets.all(6), @@ -79,7 +79,7 @@ class _NotifTileState extends State { pr.style( message: 'Accepting...', backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle(color: Theme.of(context).accentColor), + messageTextStyle: TextStyle(color: Theme.of(context).colorScheme.secondary), ); await pr.show(); await Future.delayed(Duration(seconds: 1)); @@ -93,7 +93,7 @@ class _NotifTileState extends State { }, child: Text( 'Accept', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), ), TextButton( @@ -106,7 +106,7 @@ class _NotifTileState extends State { }, child: Text( 'Decline', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), ) ], diff --git a/lib/screens/profile/userprofile.dart b/lib/screens/profile/userprofile.dart index 724f94a..6a86eb2 100644 --- a/lib/screens/profile/userprofile.dart +++ b/lib/screens/profile/userprofile.dart @@ -19,8 +19,9 @@ class MyProfile extends StatefulWidget { _MyProfileState createState() => _MyProfileState(); } -class _MyProfileState extends State with AutomaticKeepAliveClientMixin { - FirebaseUser currentUser; +class _MyProfileState extends State + with AutomaticKeepAliveClientMixin { + User currentUser; var namefirst = 'P'; final GlobalKey scaffoldKey = GlobalKey(); @@ -32,11 +33,9 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi } void _loadCurrentUser() { - FirebaseAuth.instance.currentUser().then((FirebaseUser user) { - setState(() { - // call setState to rebuild the view - currentUser = user; - }); + setState(() { + // call setState to rebuild the view + currentUser = FirebaseAuth.instance.currentUser; }); } @@ -66,11 +65,12 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi @override Widget build(BuildContext context) { super.build(context); - final currentuser = Provider.of(context); + final currentuser = Provider.of(context); return WillPopScope( onWillPop: () { Navigator.pop(context); - Navigator.push(context, MaterialPageRoute(builder: (context) => RootScreen())); + Navigator.push( + context, MaterialPageRoute(builder: (context) => RootScreen())); return Future.value(false); }, child: Scaffold( @@ -82,14 +82,18 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi elevation: 0, actions: [ TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom( + textStyle: TextStyle( + color: getVisibleColorOnPrimaryColor(context))), onPressed: () { Navigator.pushNamed(context, '/edituserdetails'); }, icon: Icon(Icons.edit), label: Text('Edit')), TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom( + textStyle: + TextStyle(color: getVisibleColorOnPrimaryColor(context))), icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: () async { await showDialog( @@ -98,34 +102,55 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi return AlertDialog( title: Text('Log out'), content: Text('Are you sure you want to log out?'), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0)), actions: [ TextButton( - child: Text('Log out', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Log out', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); + pr = ProgressDialog(context, + type: ProgressDialogType.Normal, + isDismissible: false, + showLogs: false); pr.style( message: 'Logging out...', - backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle(color: Theme.of(context).accentColor), + backgroundColor: + Theme.of(context).backgroundColor, + messageTextStyle: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ); await pr.show(); - await Future.delayed(Duration(seconds: 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p + await Future.delayed(Duration( + seconds: + 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p try { await widget._auth.signOut(); await pr.hide(); } catch (err) { await pr.hide(); String errStr = err.message ?? err.toString(); - final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + final snackBar = SnackBar( + content: Text(errStr), + duration: Duration(seconds: 3)); + ScaffoldMessenger.of(context) + .showSnackBar(snackBar); } Navigator.of(context).pop(); }, ), TextButton( - child: Text('Cancel', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Cancel', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -139,17 +164,20 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi ], ), body: StreamBuilder( - stream: Firestore.instance.collection('userdetails').document(currentuser.uid).snapshots(), + stream: FirebaseFirestore.instance + .collection('userdetails') + .doc(currentuser.uid) + .snapshots(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.active) { - name = snapshot.data['name']; - hostel = snapshot.data['hostel']; - sex = snapshot.data['sex']; - mobilenum = snapshot.data['mobileNumber']; - totalrides = snapshot.data['totalRides']; - actualrating = snapshot.data['actualRating']; - cancelledrides = snapshot.data['cancelledRides']; - numberofratings = snapshot.data['numberOfRatings']; + name = snapshot.data()['name']; + hostel = snapshot.data()['hostel']; + sex = snapshot.data()['sex']; + mobilenum = snapshot.data()['mobileNumber']; + totalrides = snapshot.data()['totalRides']; + actualrating = snapshot.data()['actualRating']; + cancelledrides = snapshot.data()['cancelledRides']; + numberofratings = snapshot.data()['numberOfRatings']; loading = false; namefirst = name.substring(0, 1); @@ -174,22 +202,26 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi alignment: Alignment.center, children: [ Container( - height: MediaQuery.of(context).size.height / 6, + height: + MediaQuery.of(context).size.height / 6, width: MediaQuery.of(context).size.width, color: Theme.of(context).primaryColor, ), Positioned( - top: MediaQuery.of(context).size.height / 6 - 74, + top: MediaQuery.of(context).size.height / 6 - + 74, child: CircleAvatar( radius: 50, - backgroundColor: Theme.of(context).accentColor, + backgroundColor: + Theme.of(context).colorScheme.secondary, child: Text( namefirst.toUpperCase(), style: TextStyle( fontSize: 48, fontFamily: 'Poiret', fontWeight: FontWeight.bold, - color: getVisibleColorOnAccentColor(context), + color: getVisibleColorOnAccentColor( + context), ), ), ), @@ -197,7 +229,8 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi ], ), Container( - margin: EdgeInsets.only(top: 50, bottom: 20, right: 20, left: 20), + margin: EdgeInsets.only( + top: 50, bottom: 20, right: 20, left: 20), child: Center( child: FittedBox( child: SelectableText( @@ -209,9 +242,11 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi ), )), Container( - margin: EdgeInsets.symmetric(horizontal: 40, vertical: 20), + margin: EdgeInsets.symmetric( + horizontal: 40, vertical: 20), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: ListTile( @@ -219,7 +254,9 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi title: Center( child: Text( 'HOSTEL', - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 20), ), ), subtitle: Center( @@ -236,7 +273,9 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi title: Center( child: Text( 'GENDER', - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 20), ), ), subtitle: Center( @@ -251,9 +290,11 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi ), ), Container( - margin: EdgeInsets.symmetric(horizontal: 30, vertical: 20), + margin: EdgeInsets.symmetric( + horizontal: 30, vertical: 20), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: ListTile( @@ -262,12 +303,14 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi child: Text( 'TOTAL RIDES', textAlign: TextAlign.center, - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 18), ), ), subtitle: Center( child: Text( - '${totalrides}', + '$totalrides', style: TextStyle(fontSize: 15), ), ), @@ -280,12 +323,14 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi child: Text( 'CANCELLED TRIPS', textAlign: TextAlign.center, - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 18), ), ), subtitle: Center( child: Text( - '${cancelledrides}', + '$cancelledrides', style: TextStyle(fontSize: 15), ), ))), @@ -293,42 +338,65 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi ), ), Container( - margin: EdgeInsets.symmetric(horizontal: 30, vertical: 20), + margin: EdgeInsets.symmetric( + horizontal: 30, vertical: 20), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: ListTile( onTap: () async { try { if (Platform.isIOS) { - await Clipboard.setData(ClipboardData(text: '${mobilenum}')).then((result) { + await Clipboard.setData( + ClipboardData( + text: '$mobilenum')) + .then((result) { final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, + backgroundColor: + Theme.of(context) + .primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ), - duration: Duration(seconds: 1), + duration: + Duration(seconds: 1), ); - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + ScaffoldMessenger.of(context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(context) + .showSnackBar(snackBar); }); } else { - await launch('tel://${mobilenum}'); + await launch('tel://$mobilenum'); } } catch (e) { - await Clipboard.setData(ClipboardData(text: '${mobilenum}')).then((result) { + await Clipboard.setData( + ClipboardData( + text: '$mobilenum')) + .then((result) { final snackBar = SnackBar( - backgroundColor: Theme.of(context).primaryColor, + backgroundColor: + Theme.of(context) + .primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ), duration: Duration(seconds: 1), ); - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + ScaffoldMessenger.of(context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(context) + .showSnackBar(snackBar); }); } }, @@ -336,7 +404,9 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi child: Text( 'MOBILE NUMBER', textAlign: TextAlign.center, - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 18), ), ), subtitle: Center( @@ -353,12 +423,14 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi child: Text( 'USER RATING', textAlign: TextAlign.center, - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 18), ), ), subtitle: Center( child: Text( - '${finalrating}', + '$finalrating', style: TextStyle(fontSize: 15), ), )), @@ -367,7 +439,8 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi ), ), Container( - margin: EdgeInsets.symmetric(horizontal: 30, vertical: 20), + margin: EdgeInsets.symmetric( + horizontal: 30, vertical: 20), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -377,7 +450,9 @@ class _MyProfileState extends State with AutomaticKeepAliveClientMixi title: Center( child: Text( 'EMAIL ID', - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 18), ), ), subtitle: Center( diff --git a/lib/screens/requests/myrequests.dart b/lib/screens/requests/myrequests.dart index dd07907..a6e249c 100644 --- a/lib/screens/requests/myrequests.dart +++ b/lib/screens/requests/myrequests.dart @@ -11,23 +11,29 @@ class MyRequests extends StatefulWidget { _MyRequestsState createState() => _MyRequestsState(); } -class _MyRequestsState extends State with AutomaticKeepAliveClientMixin { +class _MyRequestsState extends State + with AutomaticKeepAliveClientMixin { final FirebaseAuth auth = FirebaseAuth.instance; Future getOldTrips() async { - var user = await auth.currentUser(); + var user = auth.currentUser; final userid = user.uid; - var qn = await Firestore.instance.collection('group').where('users', arrayContains: userid).orderBy('end', descending: true).getDocuments(); - return qn.documents; + var qn = await FirebaseFirestore.instance + .collection('group') + .where('users', arrayContains: userid) + .orderBy('end', descending: true) + .get(); + return qn.docs; } @override Widget build(BuildContext context) { super.build(context); - final currentuser = Provider.of(context); + final currentuser = Provider.of(context); return WillPopScope( onWillPop: () { Navigator.pop(context); - Navigator.push(context, MaterialPageRoute(builder: (context) => RootScreen())); + Navigator.push( + context, MaterialPageRoute(builder: (context) => RootScreen())); return Future.value(false); }, child: Scaffold( @@ -36,7 +42,10 @@ class _MyRequestsState extends State with AutomaticKeepAliveClientMi ), body: Container( child: StreamBuilder( - stream: Firestore.instance.collection('userdetails').document(currentuser.uid).snapshots(), + stream: FirebaseFirestore.instance + .collection('userdetails') + .doc(currentuser.uid) + .snapshots(), builder: (context, usersnapshot) { return FutureBuilder( future: getOldTrips(), @@ -47,74 +56,129 @@ class _MyRequestsState extends State with AutomaticKeepAliveClientMi ); } else { return ListView.builder( - itemCount: snapshot.data == null ? 0 : snapshot.data.length, + itemCount: snapshot.data == null + ? 0 + : snapshot.data.length, itemBuilder: (ctx, index) { - final destination = snapshot.data[index].data['destination']; - final start = snapshot.data[index].data['start'].toDate(); - final end = snapshot.data[index].data['end'].toDate(); - final docId = snapshot.data[index].documentID; - final privacy = snapshot.data[index].data['privacy']; - final numberOfMembers = snapshot.data[index].data['numberOfMembers']; - final data = snapshot.data[index]; + final destination = + snapshot.data()[index].data()['destination']; + final start = snapshot + .data()[index] + .data()['start'] + .toDate(); + final end = + snapshot.data()[index].data()['end'].toDate(); + final docId = snapshot.data()[index].id; + final privacy = + snapshot.data()[index].data()['privacy']; + final numberOfMembers = snapshot + .data()[index] + .data()['numberOfMembers']; + final data = snapshot.data()[index]; return Hero( tag: Text(docId), - child: (docId != usersnapshot.data['currentGroup']) + child: (docId != + usersnapshot.data()['currentGroup']) ? Card( - color: Theme.of(context).scaffoldBackgroundColor, + color: Theme.of(context) + .scaffoldBackgroundColor, elevation: 0.0, child: InkWell( onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => EndedGroupDetails(destination, docId, privacy, start, end, numberOfMembers, data))); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + EndedGroupDetails( + destination, + docId, + privacy, + start, + end, + numberOfMembers, + data))); }, child: Card( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(25.0))), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(25.0))), elevation: 5, - margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), + margin: EdgeInsets.symmetric( + vertical: 6, horizontal: 5), child: Container( child: SingleChildScrollView( child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, children: [ Flexible( fit: FlexFit.tight, flex: 1, child: Container( - margin: EdgeInsets.only( + margin: EdgeInsets + .only( left: 20, top: 20, ), - child: snapshot.data[index].data['destination'] == 'New Delhi Railway Station' || snapshot.data[index].data['destination'] == 'Hazrat Nizamuddin Railway Station' + child: snapshot.data()[index].data()[ + 'destination'] == + 'New Delhi Railway Station' || + snapshot.data()[index].data()[ + 'destination'] == + 'Hazrat Nizamuddin Railway Station' ? Icon( - Icons.train, - color: Theme.of(context).accentColor, + Icons + .train, + color: Theme.of( + context) + .colorScheme + .secondary, size: 30, ) - : snapshot.data[index].data['destination'] == 'Indira Gandhi International Airport' + : snapshot.data()[index].data()[ + 'destination'] == + 'Indira Gandhi International Airport' ? Icon( - Icons.airplanemode_active, - color: Theme.of(context).accentColor, - size: 30, + Icons + .airplanemode_active, + color: Theme.of(context) + .colorScheme + .secondary, + size: + 30, ) : Icon( - Icons.directions_bus, - color: Theme.of(context).accentColor, - size: 30, + Icons + .directions_bus, + color: Theme.of(context) + .colorScheme + .secondary, + size: + 30, )), ), Flexible( fit: FlexFit.tight, flex: 4, child: Padding( - padding: const EdgeInsets.only(top: 10.0), + padding: + const EdgeInsets + .only( + top: 10.0), child: Text( - '${snapshot.data[index].data['destination']}', + '${snapshot.data()[index].data()['destination']}', style: TextStyle( fontSize: 17, - fontWeight: FontWeight.bold, + fontWeight: + FontWeight + .bold, ), - textAlign: TextAlign.center, + textAlign: + TextAlign + .center, ), ), ), @@ -126,10 +190,12 @@ class _MyRequestsState extends State with AutomaticKeepAliveClientMi top: 10, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment + .center, children: [ Text( - 'Started : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data[index].data['start'].toDate())}', + 'Started : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data()[index].data()['start'].toDate())}', style: TextStyle( fontSize: 15, ), @@ -142,10 +208,12 @@ class _MyRequestsState extends State with AutomaticKeepAliveClientMi bottom: 5, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment + .center, children: [ Text( - 'Ended : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data[index].data['end'].toDate())}', + 'Ended : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data()[index].data()['end'].toDate())}', style: TextStyle( fontSize: 15, ), @@ -154,12 +222,19 @@ class _MyRequestsState extends State with AutomaticKeepAliveClientMi ), ), Padding( - padding: const EdgeInsets.all(8.0), + padding: + const EdgeInsets.all( + 8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( - children: [Text('Number of poolers: ${snapshot.data[index].data['numberOfMembers'].toString()}')], + children: [ + Text( + 'Number of poolers: ${snapshot.data()[index].data()['numberOfMembers'].toString()}') + ], ), ], ), diff --git a/lib/screens/rootscreen.dart b/lib/screens/rootscreen.dart index 5beb013..6303d81 100644 --- a/lib/screens/rootscreen.dart +++ b/lib/screens/rootscreen.dart @@ -33,7 +33,7 @@ class _RootScreenState extends State { child: Icon( Icons.home, size: 20.0, - color: _selectedPage == 0 ? Theme.of(context).accentColor : Colors.white, + color: _selectedPage == 0 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -41,7 +41,7 @@ class _RootScreenState extends State { child: Icon( Icons.format_list_bulleted, size: 20.0, - color: _selectedPage == 1 ? Theme.of(context).accentColor : Colors.white, + color: _selectedPage == 1 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -49,7 +49,7 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 2 ? Icons.chat_bubble : Icons.chat_bubble_outline, size: 20.0, - color: _selectedPage == 2 ? Theme.of(context).accentColor : Colors.white, + color: _selectedPage == 2 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -57,7 +57,7 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 3 ? Icons.notifications : Icons.notifications_none, size: 20.0, - color: _selectedPage == 3 ? Theme.of(context).accentColor : Colors.white, + color: _selectedPage == 3 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -65,7 +65,7 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 4 ? Icons.person : Icons.person_outline, size: 20.0, - color: _selectedPage == 4 ? Theme.of(context).accentColor : Colors.white, + color: _selectedPage == 4 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), ]; diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 65861f2..e5c45bb 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -85,7 +85,7 @@ class _SettingsState extends State { @override Widget build(BuildContext context) { - final user = Provider.of(context); + final user = Provider.of(context); w = MediaQuery.of(context).size.width; h = MediaQuery.of(context).size.height; final themeNotifier = Provider.of(context); @@ -96,7 +96,9 @@ class _SettingsState extends State { actions: [ user != null ? TextButton.icon( - style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom( + textStyle: TextStyle( + color: getVisibleColorOnPrimaryColor(context))), icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: () async { await showDialog( @@ -105,35 +107,57 @@ class _SettingsState extends State { return AlertDialog( title: Text('Log out'), content: Text('Are you sure you want to log out?'), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0)), actions: [ TextButton( - child: Text('Log out', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Log out', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); + pr = ProgressDialog(context, + type: ProgressDialogType.Normal, + isDismissible: false, + showLogs: false); pr.style( message: 'Logging out...', - backgroundColor: Theme.of(context).backgroundColor, - messageTextStyle: TextStyle(color: Theme.of(context).accentColor), + backgroundColor: + Theme.of(context).backgroundColor, + messageTextStyle: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary), ); await pr.show(); - await Future.delayed(Duration(seconds: 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p + await Future.delayed(Duration( + seconds: + 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p try { await widget._auth.signOut(); await pr.hide(); } catch (err) { await pr.hide(); - String errStr = err.message ?? err.toString(); - final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + String errStr = + err.message ?? err.toString(); + final snackBar = SnackBar( + content: Text(errStr), + duration: Duration(seconds: 3)); + ScaffoldMessenger.of(context) + .showSnackBar(snackBar); } Navigator.of(context).pop(); Navigator.of(context).pop(); }, ), TextButton( - child: Text('Cancel', style: TextStyle(color: Theme.of(context).accentColor)), + child: Text('Cancel', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -168,13 +192,15 @@ class _SettingsState extends State { DropdownButton( icon: Icon( Icons.arrow_drop_down, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), iconSize: 30, - style: TextStyle(color: getVisibleColorOnScaffold(context), fontSize: 15), + style: TextStyle( + color: getVisibleColorOnScaffold(context), + fontSize: 15), underline: Container( height: 2, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), items: List.generate(themeList.length, (index) { return DropdownMenuItem( @@ -188,13 +214,20 @@ class _SettingsState extends State { newValueSelected != 'system' ? setState(() { _theme = newValueSelected; - _darkTheme = newValueSelected == 'dark' ? true : false; - newValueSelected == 'dark' ? onThemeChanged(true, themeNotifier) : onThemeChanged(false, themeNotifier); + _darkTheme = + newValueSelected == 'dark' ? true : false; + newValueSelected == 'dark' + ? onThemeChanged(true, themeNotifier) + : onThemeChanged(false, themeNotifier); }) : setState(() { _theme = newValueSelected; - brightness == Brightness.dark ? _darkTheme = true : _darkTheme = false; - brightness == Brightness.dark ? onThemeChanged(true, themeNotifier) : onThemeChanged(false, themeNotifier); + brightness == Brightness.dark + ? _darkTheme = true + : _darkTheme = false; + brightness == Brightness.dark + ? onThemeChanged(true, themeNotifier) + : onThemeChanged(false, themeNotifier); }); setTheme(newValueSelected); }, @@ -237,24 +270,29 @@ class _SettingsState extends State { height: w * 0.10, child: GestureDetector( child: AnimatedContainer( - margin: const EdgeInsets.symmetric(horizontal: 3), + margin: const EdgeInsets.symmetric( + horizontal: 3), + decoration: BoxDecoration( + color: colorList[index].color, + borderRadius: BorderRadius.circular( + _selectedIndex == index + ? w * 0.05 + : 0), + ), + duration: Duration(milliseconds: 300), child: _selectedIndex == index ? Icon( Icons.check, color: Colors.white, ) : null, - decoration: BoxDecoration( - color: colorList[index].color, - borderRadius: BorderRadius.circular(_selectedIndex == index ? w * 0.05 : 0), - ), - duration: Duration(milliseconds: 300), ), onTap: () { setState(() { _selectedIndex = index; }); - onColorChanged(colorList[index].value, colorList[index].color, themeNotifier); + onColorChanged(colorList[index].value, + colorList[index].color, themeNotifier); }), ); }), @@ -273,10 +311,12 @@ class _SettingsState extends State { padding: const EdgeInsets.only(left: 12.0, right: 12.0), child: Card( elevation: 0, - shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(0)), + shape: BeveledRectangleBorder( + borderRadius: BorderRadius.circular(0)), child: ListTile( onTap: () { - launch('https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); + launch( + 'https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); }, title: Text( 'Bug Report', @@ -295,7 +335,8 @@ class _SettingsState extends State { color: getVisibleTextColorOnScaffold(context), ), onPressed: () { - launch('https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); + launch( + 'https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); }, ), ), @@ -308,12 +349,14 @@ class _SettingsState extends State { } void onThemeChanged(bool value, ThemeNotifier themeNotifier) async { - themeNotifier.setTheme(getThemeDataForAccentColor(Theme.of(context).accentColor, value)); + themeNotifier.setTheme(getThemeDataForAccentColor( + Theme.of(context).colorScheme.secondary, value)); var prefs = await SharedPreferences.getInstance(); await prefs.setBool('darkMode', value); } - void onColorChanged(String value, Color accentColor, ThemeNotifier themeNotifier) async { + void onColorChanged( + String value, Color accentColor, ThemeNotifier themeNotifier) async { themeNotifier.setTheme(getThemeDataForAccentColor(accentColor, _darkTheme)); var prefs = await SharedPreferences.getInstance(); await prefs.setString('accentColor', value); @@ -370,7 +413,7 @@ class PreviewWidgetState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Switch( - activeColor: Theme.of(context).accentColor, + activeColor: Theme.of(context).colorScheme.secondary, value: switchValue, onChanged: (_) { setState(() { @@ -378,13 +421,13 @@ class PreviewWidgetState extends State { }); }), Radio( - activeColor: Theme.of(context).accentColor, + activeColor: Theme.of(context).colorScheme.secondary, groupValue: 0, value: 0, onChanged: (_) {}, ), Checkbox( - activeColor: Theme.of(context).accentColor, + activeColor: Theme.of(context).colorScheme.secondary, value: checkBoxValue, onChanged: (_) { setState(() { @@ -394,18 +437,20 @@ class PreviewWidgetState extends State { ), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all(Theme.of(context).accentColor), + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary), ), child: Text( 'BUTTON', - style: TextStyle(color: getVisibleColorOnAccentColor(context)), + style: + TextStyle(color: getVisibleColorOnAccentColor(context)), ), onPressed: () {}, ) ], ), Slider( - activeColor: Theme.of(context).accentColor, + activeColor: Theme.of(context).colorScheme.secondary, onChanged: (double newValue) { setState(() { sliderValue = newValue; diff --git a/lib/screens/tripslist.dart b/lib/screens/tripslist.dart index d504f8c..110dd39 100644 --- a/lib/screens/tripslist.dart +++ b/lib/screens/tripslist.dart @@ -15,12 +15,14 @@ class TripsList extends StatefulWidget { final _notPrivate; final _selectedDestination; final Function startCreatingTrip; - TripsList(this._dest, this._selectedDestination, this._notPrivate, {this.inGroupFetch, this.inGroup, this.startCreatingTrip}); + TripsList(this._dest, this._selectedDestination, this._notPrivate, + {this.inGroupFetch, this.inGroup, this.startCreatingTrip}); @override _TripsListState createState() => _TripsListState(); } -class _TripsListState extends State with SingleTickerProviderStateMixin { +class _TripsListState extends State + with SingleTickerProviderStateMixin { final ScrollController _controller = ScrollController(); AnimationController _hideFabController; bool flag; @@ -28,7 +30,6 @@ class _TripsListState extends State with SingleTickerProviderStateMix @override void initState() { - // TODO: implement initState super.initState(); _hideFabController = AnimationController( vsync: this, @@ -39,16 +40,19 @@ class _TripsListState extends State with SingleTickerProviderStateMix @override Widget build(BuildContext context) { - final currentuser = Provider.of(context); + final currentuser = Provider.of(context); return Scaffold( body: StreamBuilder( - stream: Firestore.instance.collection('userdetails').document(currentuser.uid).snapshots(), + stream: FirebaseFirestore.instance + .collection('userdetails') + .doc(currentuser.uid) + .snapshots(), builder: (_, usersnapshot) { if (usersnapshot.connectionState == ConnectionState.waiting) { Center(child: CircularProgressIndicator()); } if (usersnapshot.connectionState == ConnectionState.active) { - requestsArray = usersnapshot.data['currentGroupJoinRequests']; + requestsArray = usersnapshot.data()['currentGroupJoinRequests']; requestsArray ??= []; } @@ -70,12 +74,34 @@ class _TripsListState extends State with SingleTickerProviderStateMix return Container( child: StreamBuilder( stream: widget._dest == true && widget._notPrivate == true - ? Firestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).where('destination', isEqualTo: widget._selectedDestination).where('privacy', isEqualTo: false.toString()).orderBy('end', descending: true).snapshots() + ? FirebaseFirestore.instance + .collection('group') + .where('end', isGreaterThan: Timestamp.now()) + .where('destination', + isEqualTo: widget._selectedDestination) + .where('privacy', isEqualTo: false.toString()) + .orderBy('end', descending: true) + .snapshots() : widget._dest == true - ? Firestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).where('destination', isEqualTo: widget._selectedDestination).orderBy('end', descending: true).snapshots() + ? FirebaseFirestore.instance + .collection('group') + .where('end', isGreaterThan: Timestamp.now()) + .where('destination', + isEqualTo: widget._selectedDestination) + .orderBy('end', descending: true) + .snapshots() : widget._notPrivate == true - ? Firestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).where('privacy', isEqualTo: false.toString()).orderBy('end', descending: true).snapshots() - : Firestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).orderBy('end', descending: true).snapshots(), + ? FirebaseFirestore.instance + .collection('group') + .where('end', isGreaterThan: Timestamp.now()) + .where('privacy', isEqualTo: false.toString()) + .orderBy('end', descending: true) + .snapshots() + : FirebaseFirestore.instance + .collection('group') + .where('end', isGreaterThan: Timestamp.now()) + .orderBy('end', descending: true) + .snapshots(), builder: (_, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { Center(child: CircularProgressIndicator()); @@ -84,16 +110,24 @@ class _TripsListState extends State with SingleTickerProviderStateMix return ListView.builder( controller: _controller, physics: BouncingScrollPhysics(), - itemCount: snapshot.data == null ? 0 : snapshot.data.documents.length, + itemCount: snapshot.data == null + ? 0 + : snapshot.data.docs.length, itemBuilder: (ctx, index) { - final destination = snapshot.data.documents[index].data['destination']; - final start = snapshot.data.documents[index].data['start'].toDate(); - final end = snapshot.data.documents[index].data['end'].toDate(); - final docId = snapshot.data.documents[index].documentID; - final privacy = snapshot.data.documents[index].data['privacy']; - final numberOfMembers = snapshot.data.documents[index].data['numberOfMembers']; - final data = snapshot.data.documents[index]; - if (docId == usersnapshot.data['currentGroup']) { + final destination = + snapshot.data.docs[index].data()['destination']; + final start = snapshot.data.docs[index] + .data()['start'] + .toDate(); + final end = + snapshot.data.docs[index].data()['end'].toDate(); + final docId = snapshot.data.docs[index].id; + final privacy = + snapshot.data.docs[index].data()['privacy']; + final numberOfMembers = snapshot.data.docs[index] + .data()['numberOfMembers']; + final data = snapshot.data.docs[index]; + if (docId == usersnapshot.data()['currentGroup']) { flag = true; } else { flag = false; @@ -105,30 +139,51 @@ class _TripsListState extends State with SingleTickerProviderStateMix elevation: 0.0, child: InkWell( onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => GroupDetails(destination, docId, privacy, start, end, numberOfMembers, data))); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => GroupDetails( + destination, + docId, + privacy, + start, + end, + numberOfMembers, + data))); }, child: Card( shape: flag ? RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(25.0)), - side: BorderSide(color: Theme.of(context).accentColor, width: 2.0), + borderRadius: BorderRadius.all( + Radius.circular(25.0)), + side: BorderSide( + color: Theme.of(context) + .colorScheme + .secondary, + width: 2.0), ) : requestsArray.contains(docId) ? RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(25.0)), - side: BorderSide(color: Colors.pink[300], width: 2.0), + borderRadius: BorderRadius.all( + Radius.circular(25.0)), + side: BorderSide( + color: Colors.pink[300], + width: 2.0), ) : RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(25.0)), + borderRadius: BorderRadius.all( + Radius.circular(25.0)), ), elevation: 5, - margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), + margin: EdgeInsets.symmetric( + vertical: 6, horizontal: 5), child: Container( child: SingleChildScrollView( child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Flexible( fit: FlexFit.tight, @@ -138,21 +193,43 @@ class _TripsListState extends State with SingleTickerProviderStateMix left: 20, top: 20, ), - child: snapshot.data.documents[index].data['destination'] == 'New Delhi Railway Station' || snapshot.data.documents[index].data['destination'] == 'Hazrat Nizamuddin Railway Station' + child: snapshot.data.docs[index] + .data()[ + 'destination'] == + 'New Delhi Railway Station' || + snapshot.data + .docs[index] + .data()[ + 'destination'] == + 'Hazrat Nizamuddin Railway Station' ? Icon( Icons.train, - color: Theme.of(context).accentColor, + color: Theme.of( + context) + .colorScheme + .secondary, size: 30, ) - : snapshot.data.documents[index].data['destination'] == 'Indira Gandhi International Airport' + : snapshot.data.docs[index] + .data()[ + 'destination'] == + 'Indira Gandhi International Airport' ? Icon( - Icons.airplanemode_active, - color: Theme.of(context).accentColor, + Icons + .airplanemode_active, + color: Theme.of( + context) + .colorScheme + .secondary, size: 30, ) : Icon( - Icons.directions_bus, - color: Theme.of(context).accentColor, + Icons + .directions_bus, + color: Theme.of( + context) + .colorScheme + .secondary, size: 30, )), ), @@ -160,35 +237,52 @@ class _TripsListState extends State with SingleTickerProviderStateMix fit: FlexFit.tight, flex: 4, child: Padding( - padding: const EdgeInsets.only(top: 10.0), + padding: + const EdgeInsets.only( + top: 10.0), child: Text( - '${snapshot.data.documents[index].data['destination']}', + '${snapshot.data.docs[index].data()['destination']}', style: TextStyle( fontSize: 16, - fontWeight: FontWeight.bold, + fontWeight: + FontWeight.bold, ), textAlign: TextAlign.center, ), ), ), - snapshot.data.documents[index].data['privacy'] == 'true' + snapshot.data.docs[index] + .data()['privacy'] == + 'true' ? Flexible( flex: 2, child: Padding( - padding: const EdgeInsets.only(right: 25.0), + padding: + const EdgeInsets + .only( + right: 25.0), child: Icon( Icons.lock, - color: Theme.of(context).accentColor, + color: + Theme.of(context) + .colorScheme + .secondary, ), ), ) : Flexible( flex: 2, child: Padding( - padding: const EdgeInsets.only(right: 25.0), + padding: + const EdgeInsets + .only( + right: 25.0), child: Icon( Icons.lock_open, - color: Theme.of(context).accentColor, + color: + Theme.of(context) + .colorScheme + .secondary, ), ), ), @@ -200,10 +294,11 @@ class _TripsListState extends State with SingleTickerProviderStateMix top: 10, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( - 'Start : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data.documents[index].data['start'].toDate())}', + 'Start : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data.docs[index].data()['start'].toDate())}', style: TextStyle( fontSize: 15, ), @@ -216,10 +311,11 @@ class _TripsListState extends State with SingleTickerProviderStateMix bottom: 5, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( - 'End : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data.documents[index].data['end'].toDate())}', + 'End : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data.docs[index].data()['end'].toDate())}', style: TextStyle( fontSize: 15, ), @@ -230,12 +326,18 @@ class _TripsListState extends State with SingleTickerProviderStateMix Container( margin: EdgeInsets.only(bottom: 10), child: Padding( - padding: const EdgeInsets.all(8.0), + padding: + const EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( - children: [Text('Number of members in group: ${snapshot.data.documents[index].data['numberOfMembers'].toString()}/${snapshot.data.documents[index].data['maxpoolers'].toString()}')], + children: [ + Text( + 'Number of members in group: ${snapshot.data.docs[index].data()['numberOfMembers'].toString()}/${snapshot.data.docs[index].data()['maxpoolers'].toString()}') + ], ), ], ), @@ -276,7 +378,10 @@ class _TripsListState extends State with SingleTickerProviderStateMix padding: const EdgeInsets.fromLTRB(0, 20, 0, 80), child: FloatingActionButton.extended( onPressed: () { - Navigator.push(context, MaterialPageRoute(builder: (context) => GroupPage())); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => GroupPage())); }, icon: Icon(Icons.group), label: Text('Group'), diff --git a/lib/screens/wrapper.dart b/lib/screens/wrapper.dart index bae5e28..5011b7a 100644 --- a/lib/screens/wrapper.dart +++ b/lib/screens/wrapper.dart @@ -11,22 +11,24 @@ class Wrapper extends StatelessWidget { Widget build(BuildContext context) { // return either home or Authenticate widget - final user = Provider.of(context); + final user = Provider.of(context); return StreamBuilder( - stream: FirebaseAuth.instance.onAuthStateChanged, + stream: FirebaseAuth.instance.authStateChanges(), builder: (_, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Scaffold( body: Center( - child: Container(height: 200, child: Image(image: AssetImage('assets/images/logo.png'))), + child: Container( + height: 200, + child: Image(image: AssetImage('assets/images/logo.png'))), ), backgroundColor: Theme.of(context).primaryColor, ); } else { if (user == null) { return Authenticate(); - } else if (user.isEmailVerified) { + } else if (user.emailVerified) { return RootScreen(); } else { return VerificationCheck(); diff --git a/lib/services/auth.dart b/lib/services/auth.dart index a130be4..0732ac4 100644 --- a/lib/services/auth.dart +++ b/lib/services/auth.dart @@ -6,15 +6,16 @@ class AuthService { // auth change user stream - Stream get user { - return _auth.onAuthStateChanged; + Stream get user { + return _auth.authStateChanges(); } //sign in with email pass Future signInWithEmailAndPassword(String email, String password) async { - var result = await _auth.signInWithEmailAndPassword(email: email, password: password); - if (result.user.isEmailVerified) { + var result = await _auth.signInWithEmailAndPassword( + email: email, password: password); + if (result.user.emailVerified) { return true; } else { await result.user.sendEmailVerification(); @@ -22,17 +23,25 @@ class AuthService { } } - Future checkVerification(FirebaseUser user) async { - return user.isEmailVerified; + Future checkVerification(User user) async { + return user.emailVerified; } // sign up with email pass - Future registerWithEmailAndPassword({String email, String password, String name, String mobilenum, String hostel, String sex}) async { - var result = await _auth.createUserWithEmailAndPassword(email: email, password: password); + Future registerWithEmailAndPassword( + {String email, + String password, + String name, + String mobilenum, + String hostel, + String sex}) async { + var result = await _auth.createUserWithEmailAndPassword( + email: email, password: password); var user = result.user; // creating a new document for user - await DatabaseService(uid: user.uid).enterUserData(name: name, mobileNumber: mobilenum, hostel: hostel, sex: sex); + await DatabaseService(uid: user.uid).enterUserData( + name: name, mobileNumber: mobilenum, hostel: hostel, sex: sex); await result.user.sendEmailVerification(); } @@ -44,7 +53,7 @@ class AuthService { // verification mail resend - Future verificationEmail(FirebaseUser user) async { + Future verificationEmail(User user) async { await user.sendEmailVerification(); } @@ -54,30 +63,30 @@ class AuthService { } // is user verified check - Future verificationcheck(FirebaseUser user) async { + Future verificationcheck(User user) async { await user.reload(); - await user.getIdToken(refresh: true); + await user.getIdToken(true); await user.reload(); - var flag = await user.isEmailVerified; + var flag = user.emailVerified; return flag; } - Future reloadCurrentUser() async { - var oldUser = await FirebaseAuth.instance.currentUser(); + Future reloadCurrentUser() async { + var oldUser = FirebaseAuth.instance.currentUser; await oldUser.reload(); - var newUser = await FirebaseAuth.instance.currentUser(); + var newUser = FirebaseAuth.instance.currentUser; return newUser; } Future getCurrentUID() async { - var user = await _auth.currentUser(); + var user = _auth.currentUser; final uid = user.uid; return uid.toString(); } // to update email Future changeEmail(String newEmail) async { - var user = await _auth.currentUser(); + var user = _auth.currentUser; await user.updateEmail(newEmail); } } diff --git a/lib/services/database.dart b/lib/services/database.dart index be09730..a8de242 100644 --- a/lib/services/database.dart +++ b/lib/services/database.dart @@ -11,13 +11,17 @@ class DatabaseService { DatabaseService({this.uid}); //collection reference - final CollectionReference userDetails = Firestore.instance.collection('userdetails'); - final CollectionReference groupdetails = Firestore.instance.collection('group'); - final CollectionReference requests = Firestore.instance.collection('requests'); + final CollectionReference> userDetails = + FirebaseFirestore.instance.collection('userdetails'); + final CollectionReference> groupdetails = + FirebaseFirestore.instance.collection('group'); + final CollectionReference> requests = + FirebaseFirestore.instance.collection('requests'); // Enter user data (W=1, R=0) - Future enterUserData({String name, String mobileNumber, String hostel, String sex}) async { - return await userDetails.document(uid).setData({ + Future enterUserData( + {String name, String mobileNumber, String hostel, String sex}) async { + return await userDetails.doc(uid).set({ 'name': name, 'mobileNumber': mobileNumber, 'hostel': hostel, @@ -30,41 +34,47 @@ class DatabaseService { } // Update user data (W=1/2,R=1) - Future updateUserData({String name, String mobileNumber, String hostel, String sex}) async { + Future updateUserData( + {String name, String mobileNumber, String hostel, String sex}) async { var currentGrp; - var user = await _auth.currentUser(); - await Firestore.instance.collection('userdetails').document(user.uid).get().then((value) { - currentGrp = value.data['currentGroup']; + var user = _auth.currentUser; + await FirebaseFirestore.instance + .collection('userdetails') + .doc(user.uid) + .get() + .then((value) { + currentGrp = value.data()['currentGroup']; }); - await userDetails.document(uid).updateData({ + await userDetails.doc(uid).update({ 'name': name, 'mobileNumber': mobileNumber, 'hostel': hostel, 'sex': sex, }); if (currentGrp != null) { - await groupdetails.document(currentGrp).collection('users').document(user.uid).setData({ + await groupdetails.doc(currentGrp).collection('users').doc(user.uid).set({ 'name': name, 'mobilenum': mobileNumber, 'hostel': hostel, 'sex': sex, - }, merge: true); + }, SetOptions(merge: true)); } } // user list from snapshot - List _UserListFromSnapshot(QuerySnapshot snapshot) { - return snapshot.documents.map((doc) { + List _UserListFromSnapshot( + QuerySnapshot> snapshot) { + return snapshot.docs.map((doc) { return Userdetails( - uid: doc.documentID, - name: doc.data['name'] ?? '', - mobilenum: doc.data['mobileNumber'] ?? '', - hostel: doc.data['hostel'] ?? '', - sex: doc.data['sex'] ?? '', - totalrides: doc.data['totalRides'] ?? 0, - cancelledrides: doc.data['cancelledRides'] ?? 0, - actualrating: doc.data['actualRating'] ?? 0, - numberofratings: doc.data['numberOfRatings'] ?? 0, + uid: doc.id, + name: doc.data()['name'] ?? '', + mobilenum: doc.data()['mobileNumber'] ?? '', + hostel: doc.data()['hostel'] ?? '', + sex: doc.data()['sex'] ?? '', + totalrides: doc.data()['totalRides'] ?? 0, + cancelledrides: doc.data()['cancelledRides'] ?? 0, + actualrating: doc.data()['actualRating'] ?? 0, + numberofratings: doc.data()['numberOfRatings'] ?? 0, ); }).toList(); } @@ -75,20 +85,30 @@ class DatabaseService { } // get user doc - Stream get userData { - return userDetails.document(uid).snapshots(); + Stream>> get userData { + return userDetails.doc(uid).snapshots(); } // add group details (W = 4, R = 0) Future createTrip(RequestDetails requestDetails) async { - var user = await _auth.currentUser(); + var user = _auth.currentUser; // CODE FOR CONVERTING DATE TIME TO TIMESTAMP var temp = requestDetails.startTime; - var starting = DateTime(requestDetails.startDate.year, requestDetails.startDate.month, requestDetails.startDate.day, temp.hour, temp.minute); + var starting = DateTime( + requestDetails.startDate.year, + requestDetails.startDate.month, + requestDetails.startDate.day, + temp.hour, + temp.minute); var temp2 = requestDetails.endTime; - var ending = DateTime(requestDetails.endDate.year, requestDetails.endDate.month, requestDetails.endDate.day, temp2.hour, temp2.minute); + var ending = DateTime( + requestDetails.endDate.year, + requestDetails.endDate.month, + requestDetails.endDate.day, + temp2.hour, + temp2.minute); final docRef = await groupdetails.add({ 'owner': user.uid.toString(), @@ -104,78 +124,101 @@ class DatabaseService { }); //adding user to group chat - await ChatService().createChatRoom(docRef.documentID, user.uid.toString(), requestDetails.destination.toString()); + await ChatService().createChatRoom( + docRef.id, user.uid.toString(), requestDetails.destination.toString()); - await userDetails.document(user.uid).updateData({ - 'currentGroup': docRef.documentID, + await userDetails.doc(user.uid).update({ + 'currentGroup': docRef.id, }); - var request = groupdetails.document(docRef.documentID).collection('users'); - await Firestore.instance.collection('userdetails').document(user.uid).get().then((value) async { + var request = groupdetails.doc(docRef.id).collection('users'); + await FirebaseFirestore.instance + .collection('userdetails') + .doc(user.uid) + .get() + .then((value) async { if (value.exists) { - await request.document(user.uid).setData({'name': value.data['name'], 'hostel': value.data['hostel'], 'sex': value.data['sex'], 'mobilenum': value.data['mobileNumber'], 'totalrides': value.data['totalRides'], 'cancelledrides': value.data['cancelledRides'], 'actualrating': value.data['actualRating'], 'numberofratings': value.data['numberOfRatings']}); + await request.doc(user.uid).set({ + 'name': value.data()['name'], + 'hostel': value.data()['hostel'], + 'sex': value.data()['sex'], + 'mobilenum': value.data()['mobileNumber'], + 'totalrides': value.data()['totalRides'], + 'cancelledrides': value.data()['cancelledRides'], + 'actualrating': value.data()['actualRating'], + 'numberofratings': value.data()['numberOfRatings'] + }); } }); } // to update group details (W=1, R=0) - Future updateGroup(String groupUID, DateTime SD, TimeOfDay ST, DateTime ED, TimeOfDay ET, bool privacy, int maxPoolers) async { + Future updateGroup(String groupUID, DateTime SD, TimeOfDay ST, + DateTime ED, TimeOfDay ET, bool privacy, int maxPoolers) async { var starting = DateTime(SD.year, SD.month, SD.day, ST.hour, ST.minute); var ending = DateTime(ED.year, ED.month, ED.day, ET.hour, ET.minute); - await groupdetails.document(groupUID).setData({ + await groupdetails.doc(groupUID).set({ 'start': starting, 'end': ending, 'privacy': privacy.toString(), 'maxpoolers': maxPoolers, - }, merge: true); + }, SetOptions(merge: true)); } // exit a group (W=4/5, R =3/4) Future exitGroup() async { - var user = await _auth.currentUser(); + var user = _auth.currentUser; var currentGrp; var presentNum; var startTimeStamp; var totalRides; var cancelledRides; var owner; - await Firestore.instance.collection('userdetails').document(user.uid).get().then((value) { - currentGrp = value.data['currentGroup']; - totalRides = value.data['totalRides']; - cancelledRides = value.data['cancelledRides']; + await FirebaseFirestore.instance + .collection('userdetails') + .doc(user.uid) + .get() + .then((value) { + currentGrp = value.data()['currentGroup']; + totalRides = value.data()['totalRides']; + cancelledRides = value.data()['cancelledRides']; }); - await groupdetails.document(currentGrp).get().then((value) { - presentNum = value.data['numberOfMembers']; - startTimeStamp = value.data['start']; - owner = value.data['owner']; + await groupdetails.doc(currentGrp).get().then((value) { + presentNum = value.data()['numberOfMembers']; + startTimeStamp = value.data()['start']; + owner = value.data()['owner']; }); // if user leaves early, then : if (startTimeStamp.compareTo(Timestamp.now()) > 0) { - await userDetails.document(user.uid).updateData({ + await userDetails.doc(user.uid).update({ 'currentGroup': null, 'cancelledRides': cancelledRides + 1, }); - await groupdetails.document(currentGrp).updateData({ + await groupdetails.doc(currentGrp).update({ 'users': FieldValue.arrayRemove([user.uid]), 'numberOfMembers': presentNum - 1, }); if (owner == user.uid && presentNum > 1) { var newowner; - await groupdetails.document(currentGrp).get().then((value) { - newowner = value.data['users'][0]; + await groupdetails.doc(currentGrp).get().then((value) { + newowner = value.data()['users'][0]; }); - await groupdetails.document(currentGrp).updateData({ + await groupdetails.doc(currentGrp).update({ 'owner': newowner, }); } - await groupdetails.document(currentGrp).collection('users').document(user.uid).delete(); + await groupdetails + .doc(currentGrp) + .collection('users') + .doc(user.uid) + .delete(); //deleting user from chat group await ChatService().exitChatRoom(currentGrp); } // if user leaves after ride completion: else { - await userDetails.document(user.uid).updateData({ + await userDetails.doc(user.uid).update({ 'currentGroup': null, 'totalRides': totalRides + 1, 'previous_groups': FieldValue.arrayUnion([currentGrp]), @@ -184,37 +227,41 @@ class DatabaseService { // delete group if last member and startTime is greater than present time. if (presentNum == 1 && startTimeStamp.compareTo(Timestamp.now()) > 0) { - await groupdetails.document(currentGrp).delete(); + await groupdetails.doc(currentGrp).delete(); } } // join a group from dashboard (W=4,R=2) Future joinGroup(String listuid) async { - var user = await _auth.currentUser(); + var user = _auth.currentUser; var presentNum; - await userDetails.document(user.uid).updateData({ + await userDetails.doc(user.uid).update({ 'currentGroup': listuid, }); - await groupdetails.document(listuid).get().then((value) { - presentNum = value.data['numberOfMembers']; + await groupdetails.doc(listuid).get().then((value) { + presentNum = value.data()['numberOfMembers']; }); - await groupdetails.document(listuid).updateData({ + await groupdetails.doc(listuid).update({ 'users': FieldValue.arrayUnion([user.uid.toString()]), 'numberOfMembers': presentNum + 1, }); - var request = groupdetails.document(listuid).collection('users'); - await Firestore.instance.collection('userdetails').document(user.uid).get().then((value) async { + var request = groupdetails.doc(listuid).collection('users'); + await FirebaseFirestore.instance + .collection('userdetails') + .doc(user.uid) + .get() + .then((value) async { if (value.exists) { - await request.document(user.uid).setData({ - 'name': value.data['name'], - 'hostel': value.data['hostel'], - 'sex': value.data['sex'], - 'mobilenum': value.data['mobileNumber'], - 'totalrides': value.data['totalRides'], - 'actualrating': value.data['actualRating'], - 'cancelledrides': value.data['cancelledRides'], - 'numberofratings': value.data['numberOfRatings'], + await request.doc(user.uid).set({ + 'name': value.data()['name'], + 'hostel': value.data()['hostel'], + 'sex': value.data()['sex'], + 'mobilenum': value.data()['mobileNumber'], + 'totalrides': value.data()['totalRides'], + 'actualrating': value.data()['actualRating'], + 'cancelledrides': value.data()['cancelledRides'], + 'numberofratings': value.data()['numberOfRatings'], }); } }); @@ -224,21 +271,21 @@ class DatabaseService { // set device token (W=1,R=0) Future setToken(String token) async { - final user = await _auth.currentUser(); - await userDetails.document(user.uid).updateData({'device_token': token}); + final user = _auth.currentUser; + await userDetails.doc(user.uid).update({'device_token': token}); } // Function for kicking a user (ADMIN ONLY) (W=4,R=1) Future kickUser(String currentGrp, String uid) async { - await groupdetails.document(currentGrp).collection('users').document(uid).delete(); + await groupdetails.doc(currentGrp).collection('users').doc(uid).delete(); var presentNum; - await groupdetails.document(currentGrp).get().then((value) { - presentNum = value.data['numberOfMembers']; + await groupdetails.doc(currentGrp).get().then((value) { + presentNum = value.data()['numberOfMembers']; }); - await userDetails.document(uid).updateData({ + await userDetails.doc(uid).update({ 'currentGroup': null, }); - await groupdetails.document(currentGrp).updateData({ + await groupdetails.doc(currentGrp).update({ 'users': FieldValue.arrayRemove([uid]), 'numberOfMembers': presentNum - 1, }); diff --git a/lib/shared/loading.dart b/lib/shared/loading.dart index f88d7d0..c44adf3 100644 --- a/lib/shared/loading.dart +++ b/lib/shared/loading.dart @@ -8,7 +8,7 @@ class Loading extends StatelessWidget { color: Theme.of(context).scaffoldBackgroundColor, child: Center( child: SpinKitWave( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, size: 50.0, ), ), diff --git a/pubspec.lock b/pubspec.lock index e890c64..67f8e4e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -21,14 +21,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -42,21 +42,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "2.2.2" + version: "3.1.5" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "5.1.2" + version: "5.4.10" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.6.5" collection: dependency: transitive description: @@ -70,14 +70,14 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.4" curved_navigation_bar: dependency: "direct main" description: name: curved_navigation_bar url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" fake_async: dependency: transitive description: @@ -105,63 +105,63 @@ packages: name: firebase_auth url: "https://pub.dartlang.org" source: hosted - version: "1.4.1" + version: "3.3.4" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.3.1" + version: "6.1.9" firebase_auth_web: dependency: transitive description: name: firebase_auth_web url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" + version: "3.3.5" firebase_core: dependency: "direct main" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.10.6" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.1" + version: "4.2.3" firebase_core_web: dependency: transitive description: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.5.3" firebase_messaging: dependency: "direct main" description: name: firebase_messaging url: "https://pub.dartlang.org" source: hosted - version: "10.0.2" + version: "11.2.4" firebase_messaging_platform_interface: dependency: transitive description: name: firebase_messaging_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.1.4" firebase_messaging_web: dependency: transitive description: name: firebase_messaging_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.2.5" flutter: dependency: "direct main" description: flutter @@ -173,7 +173,7 @@ packages: name: flutter_spinkit url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.0" flutter_test: dependency: "direct dev" description: flutter @@ -190,7 +190,7 @@ packages: name: font_awesome_flutter url: "https://pub.dartlang.org" source: hosted - version: "9.1.0" + version: "9.2.0" http_parser: dependency: transitive description: @@ -218,14 +218,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" nested: dependency: transitive description: @@ -246,7 +246,7 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.4" path_provider_platform_interface: dependency: transitive description: @@ -260,7 +260,7 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.4" pedantic: dependency: "direct dev" description: @@ -274,21 +274,21 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" process: dependency: transitive description: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.4" progress_dialog: dependency: "direct main" description: @@ -302,28 +302,42 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "6.0.1" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.0.11" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.3" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_platform_interface: dependency: transitive description: @@ -337,14 +351,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.3" sky_engine: dependency: transitive description: flutter @@ -391,7 +405,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.3" typed_data: dependency: transitive description: @@ -405,56 +419,70 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.6" + version: "6.0.17" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.5" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.3.1" xdg_directories: dependency: transitive description: @@ -463,5 +491,5 @@ packages: source: hosted version: "0.2.0" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 38eb405..1c311b4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,10 +21,10 @@ dependencies: flutter: sdk: flutter intl: ^0.17.0 - firebase_auth: ^1.4.1 - cloud_firestore: ^2.2.2 - firebase_core: ^1.3.0 - provider: ^5.0.0 + firebase_auth: ^3.3.4 + cloud_firestore: ^3.1.5 + firebase_core: ^1.10.6 + provider: ^6.0.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. @@ -33,7 +33,7 @@ dependencies: shared_preferences: ^2.0.6 progress_dialog: ^1.2.2 font_awesome_flutter: ^9.1.0 - firebase_messaging: ^10.0.2 + firebase_messaging: ^11.2.4 url_launcher: ^6.0.6 dev_dependencies: From 63d9126681529bbc84eb793ffa3a3eb9384d9691 Mon Sep 17 00:00:00 2001 From: as1605 <1605.aditya.singh@gmail.com> Date: Sun, 19 Dec 2021 16:32:37 +0530 Subject: [PATCH 5/9] flutter analyze --- analysis_options.yaml | 2 +- lib/main.dart | 1 + lib/models/requestdetails.dart | 13 ++++++++-- lib/screens/chatscreen/chat_screen.dart | 3 ++- .../chatscreen/chat_widgets/chat_bubble.dart | 25 +++++++++++++------ lib/screens/dashboard.dart | 4 +-- lib/screens/rootscreen.dart | 24 ++++++++++++------ 7 files changed, 52 insertions(+), 20 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4c2a5d5..1ce92e9 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ include: package:pedantic/analysis_options.yaml analyzer: errors: - # omit_local_variable_types: ignore + omit_local_variable_types: ignore diff --git a/lib/main.dart b/lib/main.dart index bcc45c0..82371ec 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -268,6 +268,7 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { final themeNotifier = Provider.of(context); return StreamProvider.value( + initialData: FirebaseAuth.instance.currentUser, value: AuthService().user, child: MaterialApp( initialRoute: '/wrapper', diff --git a/lib/models/requestdetails.dart b/lib/models/requestdetails.dart index 22c4672..4ad4aca 100644 --- a/lib/models/requestdetails.dart +++ b/lib/models/requestdetails.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class RequestDetails { @@ -23,5 +22,15 @@ class RequestDetails { @required final int maxPoolers; - RequestDetails({this.name, this.id, this.destination, this.finalDestination, this.startDate, this.startTime, this.endDate, this.endTime, this.privacy, this.maxPoolers}); + RequestDetails( + {this.name, + this.id, + this.destination, + this.finalDestination, + this.startDate, + this.startTime, + this.endDate, + this.endTime, + this.privacy, + this.maxPoolers}); } diff --git a/lib/screens/chatscreen/chat_screen.dart b/lib/screens/chatscreen/chat_screen.dart index 67496bd..28b4cfa 100644 --- a/lib/screens/chatscreen/chat_screen.dart +++ b/lib/screens/chatscreen/chat_screen.dart @@ -27,7 +27,8 @@ class _ChatScreenState extends State { @override void initState() { - final fbm = FirebaseMessaging.instance..requestPermission(); + final fbm = FirebaseMessaging.instance; + fbm.requestPermission(); _getToken(); super.initState(); } diff --git a/lib/screens/chatscreen/chat_widgets/chat_bubble.dart b/lib/screens/chatscreen/chat_widgets/chat_bubble.dart index 4d76cbf..5bfda43 100644 --- a/lib/screens/chatscreen/chat_widgets/chat_bubble.dart +++ b/lib/screens/chatscreen/chat_widgets/chat_bubble.dart @@ -16,18 +16,23 @@ class MessageBubble extends StatelessWidget { clipBehavior: Clip.none, children: [ Row( - mainAxisAlignment: isMe ? MainAxisAlignment.end : MainAxisAlignment.start, + mainAxisAlignment: + isMe ? MainAxisAlignment.end : MainAxisAlignment.start, children: [ Stack( children: [ Container( decoration: BoxDecoration( - color: isMe ? Colors.grey : Theme.of(context).colorScheme.secondary, + color: isMe + ? Colors.grey + : Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.only( topLeft: Radius.circular(12), topRight: Radius.circular(12), - bottomLeft: !isMe ? Radius.circular(0) : Radius.circular(12), - bottomRight: isMe ? Radius.circular(0) : Radius.circular(12), + bottomLeft: + !isMe ? Radius.circular(0) : Radius.circular(12), + bottomRight: + isMe ? Radius.circular(0) : Radius.circular(12), ), ), padding: EdgeInsets.only( @@ -48,13 +53,17 @@ class MessageBubble extends StatelessWidget { username, style: TextStyle( fontWeight: FontWeight.bold, - color: isMe ? Colors.black : Theme.of(context).accentTextTheme.subtitle1.color, + color: isMe + ? Colors.black + : Theme.of(context).textTheme.subtitle1.color, ), ), Text( message, style: TextStyle( - color: isMe ? Colors.black : Theme.of(context).accentTextTheme.subtitle1.color, + color: isMe + ? Colors.black + : Theme.of(context).textTheme.subtitle1.color, ), textAlign: TextAlign.start, ), @@ -69,7 +78,9 @@ class MessageBubble extends StatelessWidget { Text( time, style: TextStyle( - color: isMe ? Colors.black : Theme.of(context).accentTextTheme.subtitle1.color, + color: isMe + ? Colors.black + : Theme.of(context).textTheme.subtitle1.color, fontSize: 12, ), ), diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 95582af..26dad01 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -8,7 +8,7 @@ import 'package:shareacab/models/requestdetails.dart'; import 'package:shareacab/screens/createtrip.dart'; import 'package:shareacab/screens/filter.dart'; import 'package:shareacab/screens/help.dart'; -import 'package:shareacab/screens/settings.dart' as SettingsScreen; +import 'package:shareacab/screens/settings.dart' as settings; import 'package:shareacab/screens/tripslist.dart'; import 'package:shareacab/services/auth.dart'; @@ -106,7 +106,7 @@ class _DashboardState extends State onPressed: () { return Navigator.push(context, MaterialPageRoute(builder: (context) { - return SettingsScreen.Settings(_auth); + return settings.Settings(_auth); })); }), ], diff --git a/lib/screens/rootscreen.dart b/lib/screens/rootscreen.dart index 6303d81..57aceb3 100644 --- a/lib/screens/rootscreen.dart +++ b/lib/screens/rootscreen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; import 'package:shareacab/screens/dashboard.dart'; import 'messages.dart'; import 'profile/userprofile.dart'; @@ -33,7 +32,9 @@ class _RootScreenState extends State { child: Icon( Icons.home, size: 20.0, - color: _selectedPage == 0 ? Theme.of(context).colorScheme.secondary : Colors.white, + color: _selectedPage == 0 + ? Theme.of(context).colorScheme.secondary + : Colors.white, ), ), Tooltip( @@ -41,7 +42,9 @@ class _RootScreenState extends State { child: Icon( Icons.format_list_bulleted, size: 20.0, - color: _selectedPage == 1 ? Theme.of(context).colorScheme.secondary : Colors.white, + color: _selectedPage == 1 + ? Theme.of(context).colorScheme.secondary + : Colors.white, ), ), Tooltip( @@ -49,7 +52,9 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 2 ? Icons.chat_bubble : Icons.chat_bubble_outline, size: 20.0, - color: _selectedPage == 2 ? Theme.of(context).colorScheme.secondary : Colors.white, + color: _selectedPage == 2 + ? Theme.of(context).colorScheme.secondary + : Colors.white, ), ), Tooltip( @@ -57,7 +62,9 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 3 ? Icons.notifications : Icons.notifications_none, size: 20.0, - color: _selectedPage == 3 ? Theme.of(context).colorScheme.secondary : Colors.white, + color: _selectedPage == 3 + ? Theme.of(context).colorScheme.secondary + : Colors.white, ), ), Tooltip( @@ -65,7 +72,9 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 4 ? Icons.person : Icons.person_outline, size: 20.0, - color: _selectedPage == 4 ? Theme.of(context).colorScheme.secondary : Colors.white, + color: _selectedPage == 4 + ? Theme.of(context).colorScheme.secondary + : Colors.white, ), ), ]; @@ -106,7 +115,8 @@ class _RootScreenState extends State { void bottomTapped(int index) { setState(() { _selectedPage = index; - pageController.animateToPage(index, duration: Duration(milliseconds: 200), curve: Curves.bounceInOut); + pageController.animateToPage(index, + duration: Duration(milliseconds: 200), curve: Curves.bounceInOut); }); } From 2545dc840202f0f9194062c46bbf76e2e8507e96 Mon Sep 17 00:00:00 2001 From: as1605 <1605.aditya.singh@gmail.com> Date: Sun, 19 Dec 2021 17:17:37 +0530 Subject: [PATCH 6/9] dart format . -l 900 --- lib/main.dart | 76 +-- lib/models/requestdetails.dart | 12 +- lib/screens/authenticate/change_email.dart | 25 +- .../authenticate/verified_email_check.dart | 41 +- .../chatscreen/chat_database/database.dart | 9 +- .../chatscreen/chat_widgets/chat_bubble.dart | 25 +- .../chat_widgets/chat_users_list.dart | 16 +- .../chatscreen/chat_widgets/message.dart | 3 +- .../chatscreen/chat_widgets/new_message.dart | 16 +- lib/screens/dashboard.dart | 28 +- lib/screens/edituserdetails.dart | 92 +-- .../ended_group_details.dart | 115 +--- .../groupdetailscreen/groupdetails.dart | 381 +++---------- lib/screens/groupscreen/editgroup.dart | 105 +--- lib/screens/groupscreen/group.dart | 523 +++++------------- .../notifications/services/database.dart | 68 +-- .../notifications/widgets/notifslist.dart | 29 +- lib/screens/profile/userprofile.dart | 165 ++---- lib/screens/requests/myrequests.dart | 145 ++--- lib/screens/rootscreen.dart | 23 +- lib/screens/settings.dart | 97 +--- lib/screens/tripslist.dart | 188 ++----- lib/screens/wrapper.dart | 4 +- lib/services/auth.dart | 17 +- lib/services/database.dart | 79 +-- 25 files changed, 539 insertions(+), 1743 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 82371ec..60be0ab 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -50,10 +50,8 @@ ThemeData getSearchAppBarTheme(BuildContext context) { } } -Color chatBubbleBackgroundColorReceiver = Colors - .lightBlue; // Needs to be changed acc to combinations, requires creativity -Color chatBubbleBackgroundColorSender = Colors - .lightGreen; // Needs to be changed acc to combinations, requires creativity +Color chatBubbleBackgroundColorReceiver = Colors.lightBlue; // Needs to be changed acc to combinations, requires creativity +Color chatBubbleBackgroundColorSender = Colors.lightGreen; // Needs to be changed acc to combinations, requires creativity Color chatSearchBackgroundColor = Colors.white; Color getVisibleColorOnPrimaryColor(BuildContext context) { @@ -62,12 +60,7 @@ Color getVisibleColorOnPrimaryColor(BuildContext context) { Color getVisibleColorOnAccentColor(BuildContext context) { var color = Theme.of(context).colorScheme.secondary; - var list = [ - Colors.tealAccent, - Colors.cyanAccent, - Colors.yellowAccent, - Colors.greenAccent - ]; + var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; if (list.contains(color)) { return Colors.black; } @@ -82,12 +75,7 @@ Color getVisibleTextColorOnScaffold(BuildContext context) { } else { theme = 'light'; } - var list = [ - Colors.tealAccent, - Colors.cyanAccent, - Colors.yellowAccent, - Colors.greenAccent - ]; + var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; if (list.contains(color) && theme == 'light') { return Colors.black; } else { @@ -103,12 +91,7 @@ Color getVisibleIconColorOnScaffold(BuildContext context) { } else { theme = 'light'; } - var list = [ - Colors.tealAccent, - Colors.cyanAccent, - Colors.yellowAccent, - Colors.greenAccent - ]; + var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; if (list.contains(color) && theme == 'light') { if (color == Colors.cyanAccent) { return Colors.cyan; @@ -157,8 +140,7 @@ class ThemeNotifier with ChangeNotifier { void main() { WidgetsFlutterBinding.ensureInitialized(); SharedPreferences.getInstance().then((prefs) { - if (prefs.getBool('darkMode') == null || - prefs.getString('accentColor') == null) { + if (prefs.getBool('darkMode') == null || prefs.getString('accentColor') == null) { prefs.setBool('darkMode', true); prefs.setString('accentColor', 'Blue'); } @@ -182,80 +164,63 @@ void main() { if (chosenAccentColor == 'Blue') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Cyan') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Teal') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Purple') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Red') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.redAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.redAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Orange') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Yellow') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Green') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), child: MyApp(), ), ); @@ -307,12 +272,8 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { backgroundColor: const Color(0xFF212121), dividerColor: Colors.black12, scaffoldBackgroundColor: Colors.black, - textSelectionTheme: TextSelectionThemeData( - cursorColor: Colors.white, - selectionColor: Colors.blue, - selectionHandleColor: Colors.blue), - colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) - .copyWith(secondary: accentColor), + textSelectionTheme: TextSelectionThemeData(cursorColor: Colors.white, selectionColor: Colors.blue, selectionHandleColor: Colors.blue), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(secondary: accentColor), ) : ThemeData( appBarTheme: AppBarTheme(color: Colors.black), @@ -328,7 +289,6 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { selectionColor: Colors.blueGrey[700], selectionHandleColor: Colors.blueGrey[700], ), - colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) - .copyWith(secondary: accentColor), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(secondary: accentColor), ); } diff --git a/lib/models/requestdetails.dart b/lib/models/requestdetails.dart index 4ad4aca..7d959ea 100644 --- a/lib/models/requestdetails.dart +++ b/lib/models/requestdetails.dart @@ -22,15 +22,5 @@ class RequestDetails { @required final int maxPoolers; - RequestDetails( - {this.name, - this.id, - this.destination, - this.finalDestination, - this.startDate, - this.startTime, - this.endDate, - this.endTime, - this.privacy, - this.maxPoolers}); + RequestDetails({this.name, this.id, this.destination, this.finalDestination, this.startDate, this.startTime, this.endDate, this.endTime, this.privacy, this.maxPoolers}); } diff --git a/lib/screens/authenticate/change_email.dart b/lib/screens/authenticate/change_email.dart index 647aa68..b7c0394 100644 --- a/lib/screens/authenticate/change_email.dart +++ b/lib/screens/authenticate/change_email.dart @@ -43,18 +43,7 @@ class _ChangeEmailState extends State { SizedBox(height: 20.0), TextFormField( initialValue: originalEmail, - decoration: InputDecoration( - hintText: 'Email', - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: - getBorderColorForInputFields(context), - width: 2.0)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: - Theme.of(context).colorScheme.secondary, - width: 2.0))), + decoration: InputDecoration(hintText: 'Email', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), validator: (val) { if (val.isEmpty) { return 'Enter a valid Email'; @@ -79,8 +68,7 @@ class _ChangeEmailState extends State { ), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondary), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Text( 'Change Email', @@ -94,8 +82,7 @@ class _ChangeEmailState extends State { }); await _auth.changeEmail(email); await _auth.signOut(); - await Navigator.pushNamedAndRemoveUntil( - context, '/wrapper', (route) => false); + await Navigator.pushNamedAndRemoveUntil(context, '/wrapper', (route) => false); setState(() { loading = false; }); @@ -108,8 +95,7 @@ class _ChangeEmailState extends State { error = 'Your email is invalid'; break; case 'ERROR_EMAIL_ALREADY_IN_USE': - error = - 'Email is already in use on different account'; + error = 'Email is already in use on different account'; break; default: error = 'An undefined Error happened.'; @@ -123,8 +109,7 @@ class _ChangeEmailState extends State { SizedBox(height: 24.0), Text( 'Once you change your email, please log-in again by entering your new email ID and your previous password.', - style: TextStyle( - fontSize: 17.0, fontStyle: FontStyle.italic), + style: TextStyle(fontSize: 17.0, fontStyle: FontStyle.italic), textAlign: TextAlign.justify, ), SizedBox( diff --git a/lib/screens/authenticate/verified_email_check.dart b/lib/screens/authenticate/verified_email_check.dart index b7a1ae4..74dcc6a 100644 --- a/lib/screens/authenticate/verified_email_check.dart +++ b/lib/screens/authenticate/verified_email_check.dart @@ -76,8 +76,7 @@ class _VerificationCheckState extends State { }, label: Text( 'Logout', - style: TextStyle( - color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), ), ) ], @@ -91,21 +90,14 @@ class _VerificationCheckState extends State { SizedBox(height: 20.0), RichText( text: TextSpan( - text: - 'Verification email has been sent to your ID. Please click on the verification link in your mail.', - style: TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.bold, - color: getBorderColorForInputFields(context)), + text: 'Verification email has been sent to your ID. Please click on the verification link in your mail.', + style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold, color: getBorderColorForInputFields(context)), )), SizedBox(height: 30.0), RichText( text: TextSpan( text: 'The registered email id is: $email', - style: TextStyle( - fontSize: 17.0, - color: getBorderColorForInputFields(context), - fontWeight: FontWeight.w700), + style: TextStyle(fontSize: 17.0, color: getBorderColorForInputFields(context), fontWeight: FontWeight.w700), ), ), SizedBox( @@ -116,13 +108,11 @@ class _VerificationCheckState extends State { children: [ ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondary), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Text( 'Resend email', - style: TextStyle( - color: getVisibleColorOnAccentColor(context)), + style: TextStyle(color: getVisibleColorOnAccentColor(context)), ), onPressed: () { try { @@ -138,19 +128,14 @@ class _VerificationCheckState extends State { ), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondary), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Text( 'Change email', - style: TextStyle( - color: getVisibleColorOnAccentColor(context)), + style: TextStyle(color: getVisibleColorOnAccentColor(context)), ), onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ChangeEmail())); + Navigator.push(context, MaterialPageRoute(builder: (context) => ChangeEmail())); }, ), ], @@ -158,12 +143,8 @@ class _VerificationCheckState extends State { SizedBox(height: 20.0), RichText( text: TextSpan( - text: - 'You will be auto-redirected to dashboard once you verify your account.', - style: TextStyle( - color: Colors.red, - fontSize: 20.0, - fontStyle: FontStyle.italic), + text: 'You will be auto-redirected to dashboard once you verify your account.', + style: TextStyle(color: Colors.red, fontSize: 20.0, fontStyle: FontStyle.italic), )), SizedBox(height: 20.0), ], diff --git a/lib/screens/chatscreen/chat_database/database.dart b/lib/screens/chatscreen/chat_database/database.dart index 43c5284..7e60534 100644 --- a/lib/screens/chatscreen/chat_database/database.dart +++ b/lib/screens/chatscreen/chat_database/database.dart @@ -4,14 +4,11 @@ import 'package:firebase_auth/firebase_auth.dart'; class ChatDatabase { final _auth = FirebaseAuth.instance; - final CollectionReference chatLists = - FirebaseFirestore.instance.collection('chatroom'); - final CollectionReference group = - FirebaseFirestore.instance.collection('group'); + final CollectionReference chatLists = FirebaseFirestore.instance.collection('chatroom'); + final CollectionReference group = FirebaseFirestore.instance.collection('group'); //adding user to chat room - Future createChatRoom( - String docId, String uid, String destination) async { + Future createChatRoom(String docId, String uid, String destination) async { var user = _auth.currentUser; await chatLists.doc(docId).set({ 'lastMessage': Timestamp.now(), diff --git a/lib/screens/chatscreen/chat_widgets/chat_bubble.dart b/lib/screens/chatscreen/chat_widgets/chat_bubble.dart index 5bfda43..ad07406 100644 --- a/lib/screens/chatscreen/chat_widgets/chat_bubble.dart +++ b/lib/screens/chatscreen/chat_widgets/chat_bubble.dart @@ -16,23 +16,18 @@ class MessageBubble extends StatelessWidget { clipBehavior: Clip.none, children: [ Row( - mainAxisAlignment: - isMe ? MainAxisAlignment.end : MainAxisAlignment.start, + mainAxisAlignment: isMe ? MainAxisAlignment.end : MainAxisAlignment.start, children: [ Stack( children: [ Container( decoration: BoxDecoration( - color: isMe - ? Colors.grey - : Theme.of(context).colorScheme.secondary, + color: isMe ? Colors.grey : Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.only( topLeft: Radius.circular(12), topRight: Radius.circular(12), - bottomLeft: - !isMe ? Radius.circular(0) : Radius.circular(12), - bottomRight: - isMe ? Radius.circular(0) : Radius.circular(12), + bottomLeft: !isMe ? Radius.circular(0) : Radius.circular(12), + bottomRight: isMe ? Radius.circular(0) : Radius.circular(12), ), ), padding: EdgeInsets.only( @@ -53,17 +48,13 @@ class MessageBubble extends StatelessWidget { username, style: TextStyle( fontWeight: FontWeight.bold, - color: isMe - ? Colors.black - : Theme.of(context).textTheme.subtitle1.color, + color: isMe ? Colors.black : Theme.of(context).textTheme.subtitle1.color, ), ), Text( message, style: TextStyle( - color: isMe - ? Colors.black - : Theme.of(context).textTheme.subtitle1.color, + color: isMe ? Colors.black : Theme.of(context).textTheme.subtitle1.color, ), textAlign: TextAlign.start, ), @@ -78,9 +69,7 @@ class MessageBubble extends StatelessWidget { Text( time, style: TextStyle( - color: isMe - ? Colors.black - : Theme.of(context).textTheme.subtitle1.color, + color: isMe ? Colors.black : Theme.of(context).textTheme.subtitle1.color, fontSize: 12, ), ), diff --git a/lib/screens/chatscreen/chat_widgets/chat_users_list.dart b/lib/screens/chatscreen/chat_widgets/chat_users_list.dart index 0967a4a..3fe5003 100644 --- a/lib/screens/chatscreen/chat_widgets/chat_users_list.dart +++ b/lib/screens/chatscreen/chat_widgets/chat_users_list.dart @@ -13,12 +13,7 @@ class ChatUsersList extends StatelessWidget { range = DateTime.now().subtract(Duration(days: 30)); final user = Provider.of(context); return StreamBuilder( - stream: FirebaseFirestore.instance - .collection('chatroom') - .where('users', arrayContains: user.uid) - .where('lastMessage', isGreaterThan: range) - .orderBy('lastMessage', descending: true) - .snapshots(), + stream: FirebaseFirestore.instance.collection('chatroom').where('users', arrayContains: user.uid).where('lastMessage', isGreaterThan: range).orderBy('lastMessage', descending: true).snapshots(), builder: (ctx, futureSnapshot) { if (futureSnapshot.connectionState == ConnectionState.waiting) { return Center( @@ -26,14 +21,11 @@ class ChatUsersList extends StatelessWidget { ); } return ListView.builder( - itemCount: - futureSnapshot.data == null ? 0 : futureSnapshot.data.docs.length, + itemCount: futureSnapshot.data == null ? 0 : futureSnapshot.data.docs.length, itemBuilder: (context, index) { final docId = futureSnapshot.data.docs[index].id; - final destination = - futureSnapshot.data.docs[index].data()['destination']; - final lastMessage = - futureSnapshot.data.docs[index].data()['lastMessage']; + final destination = futureSnapshot.data.docs[index].data()['destination']; + final lastMessage = futureSnapshot.data.docs[index].data()['lastMessage']; return ChatTile(docId, destination, lastMessage); }, ); diff --git a/lib/screens/chatscreen/chat_widgets/message.dart b/lib/screens/chatscreen/chat_widgets/message.dart index cc72a0e..5e7226a 100644 --- a/lib/screens/chatscreen/chat_widgets/message.dart +++ b/lib/screens/chatscreen/chat_widgets/message.dart @@ -36,8 +36,7 @@ class MessageScreen extends StatelessWidget { itemBuilder: (ctx, index) => MessageBubble( chatDocs[index]['text'], chatDocs[index]['name'], - chatDocs[index]['userId'] == - FirebaseAuth.instance.currentUser.uid, + chatDocs[index]['userId'] == FirebaseAuth.instance.currentUser.uid, key: ValueKey(chatDocs[index].id), time: DateFormat().add_jm().format( DateTime.parse( diff --git a/lib/screens/chatscreen/chat_widgets/new_message.dart b/lib/screens/chatscreen/chat_widgets/new_message.dart index ee6a945..c591845 100644 --- a/lib/screens/chatscreen/chat_widgets/new_message.dart +++ b/lib/screens/chatscreen/chat_widgets/new_message.dart @@ -19,21 +19,11 @@ class _NewMessageState extends State { FocusScope.of(context).unfocus(); _controller.clear(); final user = FirebaseAuth.instance.currentUser; - final userData = await FirebaseFirestore.instance - .collection('userdetails') - .doc(user.uid) - .get(); - await FirebaseFirestore.instance - .collection('chatroom') - .doc(widget.docId) - .update({ + final userData = await FirebaseFirestore.instance.collection('userdetails').doc(user.uid).get(); + await FirebaseFirestore.instance.collection('chatroom').doc(widget.docId).update({ 'lastMessage': Timestamp.now(), }); - await FirebaseFirestore.instance - .collection('chatroom') - .doc(widget.docId) - .collection('chats') - .add({ + await FirebaseFirestore.instance.collection('chatroom').doc(widget.docId).collection('chats').add({ 'text': _enteredMessage, 'createdAt': Timestamp.now(), 'userId': user.uid, diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 26dad01..b08f8bd 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -17,8 +17,7 @@ class Dashboard extends StatefulWidget { _DashboardState createState() => _DashboardState(); } -class _DashboardState extends State - with AutomaticKeepAliveClientMixin { +class _DashboardState extends State with AutomaticKeepAliveClientMixin { final GlobalKey scaffoldKey = GlobalKey(); final AuthService _auth = AuthService(); List filtered = allTrips; @@ -80,9 +79,7 @@ class _DashboardState extends State title: Text('Dashboard'), actions: [ TextButton.icon( - style: TextButton.styleFrom( - textStyle: - TextStyle(color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), icon: Icon( Icons.filter_list, size: 30.0, @@ -96,16 +93,14 @@ class _DashboardState extends State icon: Icon(Icons.help), tooltip: 'Help', onPressed: () { - Navigator.push( - context, MaterialPageRoute(builder: (context) => Help())); + Navigator.push(context, MaterialPageRoute(builder: (context) => Help())); }, ), IconButton( icon: Icon(Icons.settings), tooltip: 'Settings', onPressed: () { - return Navigator.push(context, - MaterialPageRoute(builder: (context) { + return Navigator.push(context, MaterialPageRoute(builder: (context) { return settings.Settings(_auth); })); }), @@ -113,12 +108,8 @@ class _DashboardState extends State ), resizeToAvoidBottomInset: false, body: StreamBuilder( - stream: FirebaseFirestore.instance - .collection('userdetails') - .doc(currentuser.uid) - .snapshots(), - builder: - (BuildContext context, AsyncSnapshot snapshot) { + stream: FirebaseFirestore.instance.collection('userdetails').doc(currentuser.uid).snapshots(), + builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.active) { var temp = snapshot.data['currentGroup']; if (temp != null) { @@ -132,17 +123,14 @@ class _DashboardState extends State } try { - if (snapshot.connectionState == ConnectionState.active && - fetched == true) { + if (snapshot.connectionState == ConnectionState.active && fetched == true) { return Scaffold( body: SingleChildScrollView( child: Column( children: [ Container( margin: EdgeInsets.all(5), - height: (MediaQuery.of(context).size.height - - MediaQuery.of(context).padding.top) * - 0.87, + height: (MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top) * 0.87, width: double.infinity, child: TripsList( _dest, diff --git a/lib/screens/edituserdetails.dart b/lib/screens/edituserdetails.dart index d234ecc..515ac2e 100644 --- a/lib/screens/edituserdetails.dart +++ b/lib/screens/edituserdetails.dart @@ -87,14 +87,12 @@ class _EditFormState extends State { ), label: Text( 'Done', - style: TextStyle( - color: getVisibleColorOnPrimaryColor(context)), + style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), )) ], ), body: Container( - padding: - EdgeInsets.symmetric(vertical: 20.0, horizontal: 60.0), + padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 60.0), child: Form( key: _formKey, child: SingleChildScrollView( @@ -104,21 +102,8 @@ class _EditFormState extends State { TextFormField( // textCapitalization: TextCapitalization.words, initialValue: snapshot.data['name'], - decoration: InputDecoration( - hintText: 'Name', - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: getBorderColorForInputFields( - context), - width: 2.0)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .colorScheme - .secondary, - width: 2.0))), - validator: (val) => - val.isEmpty ? 'Enter a valid Name' : null, + decoration: InputDecoration(hintText: 'Name', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), + validator: (val) => val.isEmpty ? 'Enter a valid Name' : null, onChanged: (val) { setState(() => name = val); }, @@ -126,52 +111,22 @@ class _EditFormState extends State { SizedBox(height: 20.0), TextFormField( initialValue: snapshot.data['mobileNumber'], - decoration: InputDecoration( - hintText: 'Mobile Number', - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: getBorderColorForInputFields( - context), - width: 2.0)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .colorScheme - .secondary, - width: 2.0))), - validator: (val) => val.length != 10 - ? 'Enter a valid mobile number.' - : null, + decoration: InputDecoration(hintText: 'Mobile Number', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), + validator: (val) => val.length != 10 ? 'Enter a valid mobile number.' : null, keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly - ], + inputFormatters: [FilteringTextInputFormatter.digitsOnly], onChanged: (val) { setState(() => mobileNum = val); }, ), SizedBox(height: 20.0), DropdownButtonFormField( - decoration: InputDecoration( - hintText: 'Select Hostel', - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: getBorderColorForInputFields( - context), - width: 2.0)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .colorScheme - .secondary, - width: 2.0))), + decoration: InputDecoration(hintText: 'Select Hostel', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), value: hostel ?? snapshot.data['hostel'], - onTap: () => FocusScope.of(context) - .requestFocus(FocusNode()), + onTap: () => FocusScope.of(context).requestFocus(FocusNode()), onChanged: (newValue) { setState(() { - FocusScope.of(context) - .requestFocus(FocusNode()); + FocusScope.of(context).requestFocus(FocusNode()); hostel = newValue; }); }, @@ -181,32 +136,16 @@ class _EditFormState extends State { child: Text(temp), ); }).toList(), - validator: (val) => val == null - ? 'Please select your hostel' - : null, + validator: (val) => val == null ? 'Please select your hostel' : null, ), SizedBox(height: 20.0), DropdownButtonFormField( - decoration: InputDecoration( - hintText: 'Select Gender', - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: getBorderColorForInputFields( - context), - width: 2.0)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .colorScheme - .secondary, - width: 2.0))), + decoration: InputDecoration(hintText: 'Select Gender', enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: getBorderColorForInputFields(context), width: 2.0)), focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0))), value: sex ?? snapshot.data['sex'], - onTap: () => FocusScope.of(context) - .requestFocus(FocusNode()), + onTap: () => FocusScope.of(context).requestFocus(FocusNode()), onChanged: (newValue) { setState(() { - FocusScope.of(context) - .requestFocus(FocusNode()); + FocusScope.of(context).requestFocus(FocusNode()); sex = newValue; }); }, @@ -216,8 +155,7 @@ class _EditFormState extends State { child: Text(temp), ); }).toList(), - validator: (val) => - val == null ? 'Please select your sex' : null, + validator: (val) => val == null ? 'Please select your sex' : null, ), SizedBox(height: 20.0), ], diff --git a/lib/screens/groupdetailscreen/ended_group_details.dart b/lib/screens/groupdetailscreen/ended_group_details.dart index 9d115c9..a7f3bdd 100644 --- a/lib/screens/groupdetailscreen/ended_group_details.dart +++ b/lib/screens/groupdetailscreen/ended_group_details.dart @@ -20,8 +20,7 @@ class EndedGroupDetails extends StatefulWidget { final numberOfMembers; final data; - EndedGroupDetails(this.destination, this.docId, this.privacy, this.start, - this.end, this.numberOfMembers, this.data); + EndedGroupDetails(this.destination, this.docId, this.privacy, this.start, this.end, this.numberOfMembers, this.data); static bool inGroup = false; @override @@ -30,11 +29,7 @@ class EndedGroupDetails extends StatefulWidget { class _EndedGroupDetailsState extends State { Future getUserDetails() async { - final userDetails = await FirebaseFirestore.instance - .collection('group') - .doc(widget.docId) - .collection('users') - .get(); + final userDetails = await FirebaseFirestore.instance.collection('group').doc(widget.docId).collection('users').get(); return userDetails.docs; } @@ -74,8 +69,7 @@ class _EndedGroupDetailsState extends State { body: Scaffold( body: NestedScrollView( controller: ScrollController(keepScrollOffset: true), - headerSliverBuilder: - (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return []; }, body: SingleChildScrollView( @@ -85,9 +79,7 @@ class _EndedGroupDetailsState extends State { tag: widget.docId, child: Card( color: Theme.of(context).colorScheme.secondary, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(25.0))), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(25.0))), elevation: 5, margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), child: Container( @@ -104,20 +96,15 @@ class _EndedGroupDetailsState extends State { margin: EdgeInsets.only( left: 20, ), - child: widget.destination == - 'New Delhi Railway Station' + child: widget.destination == 'New Delhi Railway Station' ? Icon( Icons.train, - color: Theme.of(context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, size: 30, ) : Icon( Icons.airplanemode_active, - color: Theme.of(context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, size: 30, )), ), @@ -130,12 +117,7 @@ class _EndedGroupDetailsState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - 'Started : ${DateFormat('dd.MM.yyyy - kk:mm a').format(widget.start)}', - style: TextStyle( - fontSize: 15.0, - color: getVisibleColorOnAccentColor( - context))), + Text('Started : ${DateFormat('dd.MM.yyyy - kk:mm a').format(widget.start)}', style: TextStyle(fontSize: 15.0, color: getVisibleColorOnAccentColor(context))), ], ), ), @@ -148,10 +130,7 @@ class _EndedGroupDetailsState extends State { children: [ Text( 'Ended : ${DateFormat('dd.MM.yyyy - kk:mm a').format(widget.end)}', - style: TextStyle( - fontSize: 15, - color: getVisibleColorOnAccentColor( - context)), + style: TextStyle(fontSize: 15, color: getVisibleColorOnAccentColor(context)), ), ], ), @@ -164,9 +143,7 @@ class _EndedGroupDetailsState extends State { Text( 'Number of members in group: ' '${widget.numberOfMembers}', - style: TextStyle( - color: getVisibleColorOnAccentColor( - context)), + style: TextStyle(color: getVisibleColorOnAccentColor(context)), ) ], ), @@ -183,8 +160,7 @@ class _EndedGroupDetailsState extends State { child: FutureBuilder( future: _fetchData, builder: (ctx, futureSnapshot) { - if (futureSnapshot.connectionState == - ConnectionState.waiting) { + if (futureSnapshot.connectionState == ConnectionState.waiting) { return Center( child: CircularProgressIndicator(), ); @@ -194,26 +170,20 @@ class _EndedGroupDetailsState extends State { itemCount: futureSnapshot.data.length, itemBuilder: (ctx, index) { return Container( - margin: EdgeInsets.symmetric( - vertical: 2, horizontal: 10), + margin: EdgeInsets.symmetric(vertical: 2, horizontal: 10), width: double.infinity, child: Card( elevation: 4, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( padding: const EdgeInsets.all(8.0), - child: Text(futureSnapshot - .data()[index] - .data()['name']), + child: Text(futureSnapshot.data()[index].data()['name']), ), Padding( padding: const EdgeInsets.all(8.0), - child: Text(futureSnapshot - .data()[index] - .data()['hostel']), + child: Text(futureSnapshot.data()[index].data()['hostel']), ), Padding( padding: const EdgeInsets.all(8.0), @@ -221,66 +191,39 @@ class _EndedGroupDetailsState extends State { onPressed: () async { try { if (Platform.isIOS) { - await Clipboard.setData( - ClipboardData( - text: - '${futureSnapshot.data()[index].data()['mobilenum'].toString()}')) - .then((result) { + await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data()[index].data()['mobilenum'].toString()}')).then((result) { final snackBar = SnackBar( - backgroundColor: - Theme.of(context) - .primaryColor, + backgroundColor: Theme.of(context).primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle( - color: - getVisibleColorOnPrimaryColor( - context)), + style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), ), - duration: - Duration(seconds: 1), + duration: Duration(seconds: 1), ); - ScaffoldMessenger.of(ctx) - .hideCurrentSnackBar(); - ScaffoldMessenger.of(ctx) - .showSnackBar(snackBar); + ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); + ScaffoldMessenger.of(ctx).showSnackBar(snackBar); }); } else { - await launch( - 'tel://${futureSnapshot.data()[index].data()['mobilenum'].toString()}'); + await launch('tel://${futureSnapshot.data()[index].data()['mobilenum'].toString()}'); } } catch (e) { - await Clipboard.setData( - ClipboardData( - text: - '${futureSnapshot.data()[index].data()['mobilenum'].toString()}')) - .then((result) { + await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data()[index].data()['mobilenum'].toString()}')).then((result) { final snackBar = SnackBar( - backgroundColor: - Theme.of(context) - .primaryColor, + backgroundColor: Theme.of(context).primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle( - color: - getVisibleColorOnPrimaryColor( - context)), + style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), ), - duration: - Duration(seconds: 1), + duration: Duration(seconds: 1), ); - ScaffoldMessenger.of(ctx) - .hideCurrentSnackBar(); - ScaffoldMessenger.of(ctx) - .showSnackBar(snackBar); + ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); + ScaffoldMessenger.of(ctx).showSnackBar(snackBar); }); } }, icon: Icon( Icons.phone, - color: Theme.of(context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, )), ), ], diff --git a/lib/screens/groupdetailscreen/groupdetails.dart b/lib/screens/groupdetailscreen/groupdetails.dart index 5a1818c..d83f189 100644 --- a/lib/screens/groupdetailscreen/groupdetails.dart +++ b/lib/screens/groupdetailscreen/groupdetails.dart @@ -27,24 +27,18 @@ class GroupDetails extends StatefulWidget { final numberOfMembers; final data; - GroupDetails(this.destination, this.docId, this.privacy, this.start, this.end, - this.numberOfMembers, this.data); + GroupDetails(this.destination, this.docId, this.privacy, this.start, this.end, this.numberOfMembers, this.data); static bool inGroup = false; @override _GroupDetailsState createState() => _GroupDetailsState(); } -class _GroupDetailsState extends State - with AutomaticKeepAliveClientMixin { +class _GroupDetailsState extends State with AutomaticKeepAliveClientMixin { final RequestService _request = RequestService(); final NotifServices _notifServices = NotifServices(); Future getUserDetails() async { - final userDetails = FirebaseFirestore.instance - .collection('group') - .doc(widget.docId) - .collection('users') - .snapshots(); + final userDetails = FirebaseFirestore.instance.collection('group').doc(widget.docId).collection('users').snapshots(); return userDetails; } @@ -73,17 +67,9 @@ class _GroupDetailsState extends State timeDilation = 1.0; final currentuser = Provider.of(context); return StreamBuilder( - stream: FirebaseFirestore.instance - .collection('userdetails') - .doc(currentuser.uid) - .snapshots(), + stream: FirebaseFirestore.instance.collection('userdetails').doc(currentuser.uid).snapshots(), builder: (context, usersnapshot) { - requestedToJoin = usersnapshot.hasData - ? usersnapshot.data()['currentGroupJoinRequests'] != null && - usersnapshot - .data()['currentGroupJoinRequests'] - .contains(widget.docId) - : false; + requestedToJoin = usersnapshot.hasData ? usersnapshot.data()['currentGroupJoinRequests'] != null && usersnapshot.data()['currentGroupJoinRequests'].contains(widget.docId) : false; if (usersnapshot.connectionState == ConnectionState.active) { var groupUID = usersnapshot.data()['currentGroup']; if (groupUID != null) { @@ -92,20 +78,14 @@ class _GroupDetailsState extends State GroupDetails.inGroup = false; } return StreamBuilder( - stream: FirebaseFirestore.instance - .collection('group') - .doc(widget.docId) - .snapshots(), + stream: FirebaseFirestore.instance.collection('group').doc(widget.docId).snapshots(), builder: (context, groupsnapshot) { if (groupsnapshot.connectionState == ConnectionState.active) { privacy = groupsnapshot.data()['privacy']; destination = groupsnapshot.data()['destination']; - start = DateFormat('dd.MM.yyyy - kk:mm a') - .format(groupsnapshot.data()['start'].toDate()); - end = DateFormat('dd.MM.yyyy - kk:mm a') - .format(groupsnapshot.data()['end'].toDate()); - presentNum = - groupsnapshot.data()['numberOfMembers'].toString(); + start = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data()['start'].toDate()); + end = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data()['end'].toDate()); + presentNum = groupsnapshot.data()['numberOfMembers'].toString(); present = int.parse(presentNum); max = groupsnapshot.data()['maxpoolers']; if (present >= max) { @@ -115,8 +95,7 @@ class _GroupDetailsState extends State } return NestedScrollView( controller: ScrollController(keepScrollOffset: true), - headerSliverBuilder: - (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( pinned: true, @@ -130,10 +109,8 @@ class _GroupDetailsState extends State }, body: Scaffold( body: NestedScrollView( - controller: - ScrollController(keepScrollOffset: true), - headerSliverBuilder: (BuildContext context, - bool innerBoxIsScrolled) { + controller: ScrollController(keepScrollOffset: true), + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return []; }, body: SingleChildScrollView( @@ -142,23 +119,16 @@ class _GroupDetailsState extends State Hero( tag: widget.docId, child: Card( - color: Theme.of(context) - .colorScheme - .secondary, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(25.0))), + color: Theme.of(context).colorScheme.secondary, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(25.0))), elevation: 5, - margin: EdgeInsets.symmetric( - vertical: 6, horizontal: 5), + margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), child: Container( height: 120, child: Column( children: [ Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( fit: FlexFit.tight, @@ -167,24 +137,15 @@ class _GroupDetailsState extends State margin: EdgeInsets.only( left: 20, ), - child: widget - .destination == - 'New Delhi Railway Station' + child: widget.destination == 'New Delhi Railway Station' ? Icon( Icons.train, - color: Theme.of( - context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, size: 30, ) : Icon( - Icons - .airplanemode_active, - color: Theme.of( - context) - .colorScheme - .secondary, + Icons.airplanemode_active, + color: Theme.of(context).colorScheme.secondary, size: 30, )), ), @@ -195,15 +156,9 @@ class _GroupDetailsState extends State bottom: 5, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('Start : $start', - style: TextStyle( - fontSize: 15.0, - color: - getVisibleColorOnAccentColor( - context))), + Text('Start : $start', style: TextStyle(fontSize: 15.0, color: getVisibleColorOnAccentColor(context))), ], ), ), @@ -212,37 +167,26 @@ class _GroupDetailsState extends State bottom: 5, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'End : $end', - style: TextStyle( - fontSize: 15, - color: - getVisibleColorOnAccentColor( - context)), + style: TextStyle(fontSize: 15, color: getVisibleColorOnAccentColor(context)), ), ], ), ), Padding( - padding: const EdgeInsets.only( - bottom: 5), + padding: const EdgeInsets.only(bottom: 5), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( children: [ Text( 'Number of members in group: ' '$presentNum', - style: TextStyle( - color: - getVisibleColorOnAccentColor( - context)), + style: TextStyle(color: getVisibleColorOnAccentColor(context)), ) ], ), @@ -250,18 +194,14 @@ class _GroupDetailsState extends State ), ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( children: [ Text( 'Max Number of members: ' '$max', - style: TextStyle( - color: - getVisibleColorOnAccentColor( - context)), + style: TextStyle(color: getVisibleColorOnAccentColor(context)), ) ], ), @@ -274,17 +214,11 @@ class _GroupDetailsState extends State ), Container( margin: EdgeInsets.only(top: 60), - height: MediaQuery.of(context).size.height * - 0.7, + height: MediaQuery.of(context).size.height * 0.7, child: StreamBuilder( - stream: FirebaseFirestore.instance - .collection('group') - .doc(widget.docId) - .collection('users') - .snapshots(), + stream: FirebaseFirestore.instance.collection('group').doc(widget.docId).collection('users').snapshots(), builder: (ctx, futureSnapshot) { - if (futureSnapshot.connectionState == - ConnectionState.waiting) { + if (futureSnapshot.connectionState == ConnectionState.waiting) { return Column( children: [ CircularProgressIndicator(), @@ -292,126 +226,64 @@ class _GroupDetailsState extends State ); } return ListView.builder( - physics: - NeverScrollableScrollPhysics(), - itemCount: - futureSnapshot.data.docs.length, + physics: NeverScrollableScrollPhysics(), + itemCount: futureSnapshot.data.docs.length, itemBuilder: (ctx, index) { return Container( - margin: EdgeInsets.symmetric( - vertical: 2, - horizontal: 10), + margin: EdgeInsets.symmetric(vertical: 2, horizontal: 10), width: double.infinity, child: Card( elevation: 4, child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Padding( - padding: - const EdgeInsets - .all(8.0), - child: Text( - futureSnapshot.data - .docs[index] - .data()[ - 'name']), + padding: const EdgeInsets.all(8.0), + child: Text(futureSnapshot.data.docs[index].data()['name']), ), Padding( - padding: - const EdgeInsets - .all(8.0), - child: Text( - futureSnapshot.data - .docs[index] - .data()[ - 'hostel']), + padding: const EdgeInsets.all(8.0), + child: Text(futureSnapshot.data.docs[index].data()['hostel']), ), Padding( - padding: - const EdgeInsets - .all(8.0), + padding: const EdgeInsets.all(8.0), child: IconButton( - onPressed: - () async { + onPressed: () async { try { - if (Platform - .isIOS) { - await Clipboard.setData(ClipboardData( - text: - '${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}')) - .then( - (result) { - final snackBar = - SnackBar( - backgroundColor: - Theme.of(context) - .primaryColor, - content: - Text( + if (Platform.isIOS) { + await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}')).then((result) { + final snackBar = SnackBar( + backgroundColor: Theme.of(context).primaryColor, + content: Text( 'Copied to Clipboard', - style: TextStyle( - color: - getVisibleColorOnPrimaryColor(context)), + style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), ), - duration: Duration( - seconds: - 1), + duration: Duration(seconds: 1), ); - ScaffoldMessenger.of( - ctx) - .hideCurrentSnackBar(); - ScaffoldMessenger.of( - ctx) - .showSnackBar( - snackBar); + ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); + ScaffoldMessenger.of(ctx).showSnackBar(snackBar); }); } else { - await launch( - 'tel://${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}'); + await launch('tel://${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}'); } } catch (e) { - await Clipboard.setData( - ClipboardData( - text: - '${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}')) - .then( - (result) { - final snackBar = - SnackBar( - backgroundColor: - Theme.of(context) - .primaryColor, - content: - Text( + await Clipboard.setData(ClipboardData(text: '${futureSnapshot.data.docs[index].data()['mobilenum'].toString()}')).then((result) { + final snackBar = SnackBar( + backgroundColor: Theme.of(context).primaryColor, + content: Text( 'Copied to Clipboard', - style: TextStyle( - color: - getVisibleColorOnPrimaryColor(context)), + style: TextStyle(color: getVisibleColorOnPrimaryColor(context)), ), - duration: Duration( - seconds: - 1), + duration: Duration(seconds: 1), ); - ScaffoldMessenger - .of(ctx) - .hideCurrentSnackBar(); - ScaffoldMessenger - .of( - ctx) - .showSnackBar( - snackBar); + ScaffoldMessenger.of(ctx).hideCurrentSnackBar(); + ScaffoldMessenger.of(ctx).showSnackBar(snackBar); }); } }, icon: Icon( Icons.phone, - color: Theme.of( - context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, )), ), ], @@ -428,19 +300,14 @@ class _GroupDetailsState extends State ), bottomNavigationBar: TextButton( style: TextButton.styleFrom( - textStyle: TextStyle( - color: - getVisibleColorOnPrimaryColor(context)), + textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context)), padding: EdgeInsets.all(20), ), onPressed: () async { try { if (GroupDetails.inGroup) { - await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => GroupPage())); + await Navigator.push(context, MaterialPageRoute(builder: (context) => GroupPage())); } else if (full) { null; } else if (privacy == 'true' && !full) { @@ -451,46 +318,24 @@ class _GroupDetailsState extends State context: context, builder: (BuildContext ctx) { return AlertDialog( - title: - Text('Request To Join Group'), - content: Text( - 'Are you sure you want to request to join this group?'), + title: Text('Request To Join Group'), + content: Text('Are you sure you want to request to join this group?'), actions: [ TextButton( - child: Text('Request', - style: TextStyle( - color: - Theme.of(context) - .colorScheme - .secondary)), + child: Text('Request', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, - type: ProgressDialogType - .Normal, - isDismissible: false, - showLogs: false); + pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); pr.style( message: 'Requesting...', - backgroundColor: - Theme.of(context) - .backgroundColor, - messageTextStyle: - TextStyle( - color: Theme.of( - context) - .colorScheme - .secondary), + backgroundColor: Theme.of(context).backgroundColor, + messageTextStyle: TextStyle(color: Theme.of(context).colorScheme.secondary), ); await pr.show(); - await Future.delayed( - Duration(seconds: 1)); + await Future.delayed(Duration(seconds: 1)); try { - await _notifServices - .createRequest( - widget.docId); - Navigator.of(context) - .pop(); + await _notifServices.createRequest(widget.docId); + Navigator.of(context).pop(); await pr.hide(); } catch (e) { await pr.hide(); @@ -499,12 +344,7 @@ class _GroupDetailsState extends State }, ), TextButton( - child: Text('Cancel', - style: TextStyle( - color: - Theme.of(context) - .colorScheme - .secondary)), + child: Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -518,44 +358,24 @@ class _GroupDetailsState extends State builder: (BuildContext ctx) { return AlertDialog( title: Text('Join Group'), - content: Text( - 'Are you sure you want to join this group?'), + content: Text('Are you sure you want to join this group?'), actions: [ TextButton( - child: Text('Join', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary)), + child: Text('Join', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, - type: ProgressDialogType - .Normal, - isDismissible: false, - showLogs: false); + pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); pr.style( message: 'Joining Group...', - backgroundColor: - Theme.of(context) - .backgroundColor, - messageTextStyle: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + backgroundColor: Theme.of(context).backgroundColor, + messageTextStyle: TextStyle(color: Theme.of(context).colorScheme.secondary), ); await pr.show(); - await Future.delayed( - Duration(seconds: 1)); + await Future.delayed(Duration(seconds: 1)); try { - await _request - .joinGroup(widget.docId); + await _request.joinGroup(widget.docId); GroupDetails.inGroup = true; - await _notifServices - .groupJoin( - usersnapshot - .data()['name'], - widget.docId); + await _notifServices.groupJoin(usersnapshot.data()['name'], widget.docId); await pr.hide(); } catch (e) { await pr.hide(); @@ -575,11 +395,7 @@ class _GroupDetailsState extends State }, ), TextButton( - child: Text('Cancel', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary)), + child: Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -596,46 +412,27 @@ class _GroupDetailsState extends State ? GroupDetails.inGroup ? Text( 'My Group Page', // You are in a group and viewing a private group - style: TextStyle( - fontSize: 20, - color: getVisibleColorOnAccentColor( - context)), + style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), ) : full - ? Text('Group is full', - style: TextStyle(fontSize: 20)) + ? Text('Group is full', style: TextStyle(fontSize: 20)) : requestedToJoin ? Text( 'Requested', // You are not in any group and requested to join - style: TextStyle( - fontSize: 20, - color: - getVisibleColorOnAccentColor( - context)), + style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), ) : Text( 'Request to Join', // fresh visit to private group (and user is not in any group) - style: TextStyle( - fontSize: 20, - color: - getVisibleColorOnAccentColor( - context)), + style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), ) : GroupDetails.inGroup ? Text( 'My Group Page', // visiting a group page - style: TextStyle( - fontSize: 20, - color: getVisibleColorOnAccentColor( - context)), + style: TextStyle(fontSize: 20, color: getVisibleColorOnAccentColor(context)), ) : full - ? Text('Group is full', - style: TextStyle(fontSize: 20)) - : Text('Join Now', - style: TextStyle( - fontSize: - 20)), // Visiting a public group page and not in any group + ? Text('Group is full', style: TextStyle(fontSize: 20)) + : Text('Join Now', style: TextStyle(fontSize: 20)), // Visiting a public group page and not in any group ), )); } else { diff --git a/lib/screens/groupscreen/editgroup.dart b/lib/screens/groupscreen/editgroup.dart index ce22384..1ffc4df 100644 --- a/lib/screens/groupscreen/editgroup.dart +++ b/lib/screens/groupscreen/editgroup.dart @@ -35,24 +35,14 @@ class _EditGroupState extends State { void _updateGroup() async { try { - await _databaseService.updateGroup( - groupUID, - _selectedStartDate, - _selectedStartTime, - _selectedEndDate, - _selectedEndTime, - privacy, - _maxPoolers); + await _databaseService.updateGroup(groupUID, _selectedStartDate, _selectedStartTime, _selectedEndDate, _selectedEndTime, privacy, _maxPoolers); } catch (e) { print(e.toString()); } } void _submitData() { - if (_selectedStartDate == null || - _selectedStartTime == null || - _selectedEndDate == null || - _selectedEndTime == null) { + if (_selectedStartDate == null || _selectedStartTime == null || _selectedEndDate == null || _selectedEndTime == null) { return; //return stops function execution and thus nothing is called or returned } setState(() { @@ -62,12 +52,7 @@ class _EditGroupState extends State { } void _startDatePicker() { - showDatePicker( - context: context, - initialDate: _selectedStartDate, - firstDate: DateTime.parse(_selectedStartDate.toString()), - lastDate: DateTime.now().add(Duration(days: 30))) - .then((pickedDate) { + showDatePicker(context: context, initialDate: _selectedStartDate, firstDate: DateTime.parse(_selectedStartDate.toString()), lastDate: DateTime.now().add(Duration(days: 30))).then((pickedDate) { if (pickedDate == null) { return; } @@ -79,12 +64,7 @@ class _EditGroupState extends State { } void _endDatePicker() { - showDatePicker( - context: context, - initialDate: _selectedEndDate, - firstDate: DateTime.parse(_selectedEndDate.toString()), - lastDate: DateTime.now().add(Duration(days: 30))) - .then((pickedDate) { + showDatePicker(context: context, initialDate: _selectedEndDate, firstDate: DateTime.parse(_selectedEndDate.toString()), lastDate: DateTime.now().add(Duration(days: 30))).then((pickedDate) { if (pickedDate == null) { return; } @@ -146,16 +126,13 @@ class _EditGroupState extends State { ); } - Widget buildContainer(String point, DateTime date, TimeOfDay time, - Function DatePicker, Function TimePicker) { + Widget buildContainer(String point, DateTime date, TimeOfDay time, Function DatePicker, Function TimePicker) { return Container( margin: EdgeInsets.only(top: 20, left: 30, right: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Text(date == null - ? '$point Date' - : '${DateFormat.yMd().format(date)}'), + Text(date == null ? '$point Date' : '${DateFormat.yMd().format(date)}'), IconButton( icon: Icon( Icons.calendar_today, @@ -163,9 +140,7 @@ class _EditGroupState extends State { ), onPressed: () => DatePicker(), ), - Text(time == null - ? '$point Time' - : '${time.toString().substring(10, 15)}'), + Text(time == null ? '$point Time' : '${time.toString().substring(10, 15)}'), IconButton( icon: Icon( Icons.schedule, @@ -180,21 +155,15 @@ class _EditGroupState extends State { @override void initState() { - FirebaseFirestore.instance - .collection('group') - .doc(groupUID) - .get() - .then((value) { + FirebaseFirestore.instance.collection('group').doc(groupUID).get().then((value) { setState(() { startTS = value.data()['start']; endTS = value.data()['end']; tempPrivacy = value.data()['privacy']; _selectedStartDate = startTS.toDate(); _selectedEndDate = endTS.toDate(); - _selectedStartTime = TimeOfDay( - hour: _selectedStartDate.hour, minute: _selectedStartDate.minute); - _selectedEndTime = TimeOfDay( - hour: _selectedEndDate.hour, minute: _selectedEndDate.minute); + _selectedStartTime = TimeOfDay(hour: _selectedStartDate.hour, minute: _selectedStartDate.minute); + _selectedEndTime = TimeOfDay(hour: _selectedEndDate.hour, minute: _selectedEndDate.minute); _maxPoolers = value.data()['maxpoolers']; }); if (tempPrivacy == 'true') { @@ -225,21 +194,14 @@ class _EditGroupState extends State { child: Column( children: [ buildLabel('Starting'), - buildContainer( - 'Start', - _selectedStartDate, - _selectedStartTime, - _startDatePicker, - _startTimePicker), + buildContainer('Start', _selectedStartDate, _selectedStartTime, _startDatePicker, _startTimePicker), buildLabel('Ending'), - buildContainer('End', _selectedEndDate, _selectedEndTime, - _endDatePicker, _endTimePicker), + buildContainer('End', _selectedEndDate, _selectedEndTime, _endDatePicker, _endTimePicker), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: - const EdgeInsets.only(top: 30.0, left: 40.0), + padding: const EdgeInsets.only(top: 30.0, left: 40.0), child: Text('Max No. of poolers:', style: TextStyle( fontSize: 20.0, @@ -260,9 +222,7 @@ class _EditGroupState extends State { child: Text( dropDownIntItem.toString(), style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, ), ), ); @@ -292,10 +252,8 @@ class _EditGroupState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Checkbox( - checkColor: - getVisibleColorOnAccentColor(context), - activeColor: - Theme.of(context).colorScheme.secondary, + checkColor: getVisibleColorOnAccentColor(context), + activeColor: Theme.of(context).colorScheme.secondary, value: privacy, onChanged: (bool value) { setState(() { @@ -320,43 +278,26 @@ class _EditGroupState extends State { child: ElevatedButton( style: ElevatedButton.styleFrom( primary: Theme.of(context).colorScheme.secondary, - textStyle: TextStyle( - color: getVisibleColorOnAccentColor(context)), + textStyle: TextStyle(color: getVisibleColorOnAccentColor(context)), ), onPressed: () { - var starting = DateTime( - _selectedStartDate.year, - _selectedStartDate.month, - _selectedStartDate.day, - _selectedStartTime.hour, - _selectedStartTime.minute); - var ending = DateTime( - _selectedEndDate.year, - _selectedEndDate.month, - _selectedEndDate.day, - _selectedEndTime.hour, - _selectedEndTime.minute); + var starting = DateTime(_selectedStartDate.year, _selectedStartDate.month, _selectedStartDate.day, _selectedStartTime.hour, _selectedStartTime.minute); + var ending = DateTime(_selectedEndDate.year, _selectedEndDate.month, _selectedEndDate.day, _selectedEndTime.hour, _selectedEndTime.minute); if (starting.compareTo(ending) < 0) { _submitData(); } else { - ScaffoldMessenger.of(context) - .hideCurrentSnackBar(); - ScaffoldMessenger.of(context) - .showSnackBar(SnackBar( + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: Theme.of(context).primaryColor, duration: Duration(seconds: 2), content: Text( 'INVALID : Start Time > End Time', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), )); } }, - child: Text('Update Trip', - style: TextStyle(fontSize: 18)), + child: Text('Update Trip', style: TextStyle(fontSize: 18)), ), ), ], diff --git a/lib/screens/groupscreen/group.dart b/lib/screens/groupscreen/group.dart index 743efd5..e0091aa 100644 --- a/lib/screens/groupscreen/group.dart +++ b/lib/screens/groupscreen/group.dart @@ -21,8 +21,7 @@ class GroupPage extends StatefulWidget { _GroupPageState createState() => _GroupPageState(); } -class _GroupPageState extends State - with AutomaticKeepAliveClientMixin { +class _GroupPageState extends State with AutomaticKeepAliveClientMixin { final RequestService _request = RequestService(); final NotifServices _notifServices = NotifServices(); final GlobalKey scaffoldKey = GlobalKey(); @@ -45,11 +44,7 @@ class _GroupPageState extends State double userRating; Future getMembers(String docid) async { - var qp = await FirebaseFirestore.instance - .collection('group') - .doc(docid) - .collection('users') - .get(); + var qp = await FirebaseFirestore.instance.collection('group').doc(docid).collection('users').get(); return qp.docs; } @@ -63,10 +58,7 @@ class _GroupPageState extends State super.build(context); final currentuser = Provider.of(context); return StreamBuilder( - stream: FirebaseFirestore.instance - .collection('userdetails') - .doc(currentuser.uid) - .snapshots(), + stream: FirebaseFirestore.instance.collection('userdetails').doc(currentuser.uid).snapshots(), builder: (context, usersnapshot) { if (usersnapshot.connectionState == ConnectionState.active) { if (buttonEnabled == true) { @@ -76,21 +68,15 @@ class _GroupPageState extends State Navigator.pop(context); } return StreamBuilder( - stream: FirebaseFirestore.instance - .collection('group') - .doc(groupUID) - .snapshots(), + stream: FirebaseFirestore.instance.collection('group').doc(groupUID).snapshots(), builder: (context, groupsnapshot) { if (groupsnapshot.connectionState == ConnectionState.active) { if (buttonEnabled == true) { destination = groupsnapshot.data()['destination']; - start = DateFormat('dd.MM.yyyy - kk:mm a') - .format(groupsnapshot.data()['start'].toDate()); - end = DateFormat('dd.MM.yyyy - kk:mm a') - .format(groupsnapshot.data()['end'].toDate()); + start = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data()['start'].toDate()); + end = DateFormat('dd.MM.yyyy - kk:mm a').format(groupsnapshot.data()['end'].toDate()); grpOwner = groupsnapshot.data()['owner']; - presentNum = - groupsnapshot.data()['numberOfMembers'].toString(); + presentNum = groupsnapshot.data()['numberOfMembers'].toString(); endTimeStamp = groupsnapshot.data()['end']; maxPoolers = groupsnapshot.data()['maxpoolers']; loading = false; @@ -107,107 +93,51 @@ class _GroupPageState extends State buttonEnabled ? timestampFlag ? TextButton.icon( - style: TextButton.styleFrom( - textStyle: TextStyle( - color: - getVisibleColorOnPrimaryColor( - context))), - icon: Icon( - FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: () async { try { await showDialog( context: context, - builder: - (BuildContext ctx) { + builder: (BuildContext ctx) { return AlertDialog( title: Text('End Trip'), - content: Text( - 'Are you sure you want to end this trip?'), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius - .circular( - 20.0)), + content: Text('Are you sure you want to end this trip?'), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), actions: [ TextButton( - child: Text('End', - style: TextStyle( - color: Theme.of( - context) - .colorScheme - .secondary)), - onPressed: - () async { + child: Text('End', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), + onPressed: () async { ProgressDialog pr; - pr = ProgressDialog( - context, - type: ProgressDialogType - .Normal, - isDismissible: - false, - showLogs: - false); + pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); pr.style( - message: - 'Ending Trip...', - backgroundColor: - Theme.of( - context) - .backgroundColor, - messageTextStyle: - TextStyle( - color: getVisibleTextColorOnScaffold( - context), + message: 'Ending Trip...', + backgroundColor: Theme.of(context).backgroundColor, + messageTextStyle: TextStyle( + color: getVisibleTextColorOnScaffold(context), ), ); await pr.show(); - await Future.delayed( - Duration( - seconds: - 1)); + await Future.delayed(Duration(seconds: 1)); try { - buttonEnabled = - false; - await _request - .exitGroup(); - Navigator.pop( - context); + buttonEnabled = false; + await _request.exitGroup(); + Navigator.pop(context); await pr.hide(); } catch (e) { await pr.hide(); - print(e - .toString()); - String errStr = - e.message ?? - e.toString(); - final snackBar = SnackBar( - content: Text( - errStr), - duration: Duration( - seconds: - 3)); - ScaffoldMessenger.of( - context) - .showSnackBar( - snackBar); + print(e.toString()); + String errStr = e.message ?? e.toString(); + final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); + ScaffoldMessenger.of(context).showSnackBar(snackBar); } - Navigator.pop( - context); + Navigator.pop(context); }, ), TextButton( - child: Text( - 'Cancel', - style: TextStyle( - color: Theme.of( - context) - .colorScheme - .secondary)), + child: Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () { - Navigator.of( - context) - .pop(); + Navigator.of(context).pop(); }, ), ], @@ -220,113 +150,52 @@ class _GroupPageState extends State label: Text('End Trip'), ) : TextButton.icon( - style: TextButton.styleFrom( - textStyle: TextStyle( - color: - getVisibleColorOnPrimaryColor( - context))), - icon: Icon( - FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: () async { try { await showDialog( context: context, - builder: - (BuildContext ctx) { + builder: (BuildContext ctx) { return AlertDialog( - title: - Text('Leave Group'), - content: Text( - 'Are you sure you want to leave this group?'), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius - .circular( - 20.0)), + title: Text('Leave Group'), + content: Text('Are you sure you want to leave this group?'), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), actions: [ TextButton( - child: Text('Leave', - style: TextStyle( - color: Theme.of( - context) - .colorScheme - .secondary)), - onPressed: - () async { + child: Text('Leave', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), + onPressed: () async { ProgressDialog pr; - pr = ProgressDialog( - context, - type: ProgressDialogType - .Normal, - isDismissible: - false, - showLogs: - false); + pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); pr.style( - message: - 'Leaving Group...', - backgroundColor: - Theme.of( - context) - .backgroundColor, - messageTextStyle: - TextStyle( - color: getVisibleTextColorOnScaffold( - context), + message: 'Leaving Group...', + backgroundColor: Theme.of(context).backgroundColor, + messageTextStyle: TextStyle( + color: getVisibleTextColorOnScaffold(context), ), ); await pr.show(); - await Future.delayed( - Duration( - seconds: - 1)); + await Future.delayed(Duration(seconds: 1)); try { - buttonEnabled = - false; - await _notifServices.leftGroup( - usersnapshot - .data()[ - 'name'], - groupUID); - await _request - .exitGroup(); - Navigator.pop( - context); + buttonEnabled = false; + await _notifServices.leftGroup(usersnapshot.data()['name'], groupUID); + await _request.exitGroup(); + Navigator.pop(context); await pr.hide(); } catch (e) { await pr.hide(); - print(e - .toString()); - String errStr = - e.message ?? - e.toString(); - final snackBar = SnackBar( - content: Text( - errStr), - duration: Duration( - seconds: - 3)); - ScaffoldMessenger.of( - context) - .showSnackBar( - snackBar); + print(e.toString()); + String errStr = e.message ?? e.toString(); + final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); + ScaffoldMessenger.of(context).showSnackBar(snackBar); } - Navigator.pop( - context); + Navigator.pop(context); }, ), TextButton( - child: Text( - 'Cancel', - style: TextStyle( - color: Theme.of( - context) - .colorScheme - .secondary)), + child: Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () { - Navigator.of( - context) - .pop(); + Navigator.of(context).pop(); }, ), ], @@ -340,24 +209,14 @@ class _GroupPageState extends State ) : timestampFlag ? TextButton.icon( - style: TextButton.styleFrom( - textStyle: TextStyle( - color: - getVisibleColorOnPrimaryColor( - context))), - icon: Icon( - FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: null, label: Text('End Trip'), ) : TextButton.icon( - style: TextButton.styleFrom( - textStyle: TextStyle( - color: - getVisibleColorOnPrimaryColor( - context))), - icon: Icon( - FontAwesomeIcons.signOutAlt), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), + icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: null, label: Text('Leave Group'), ) @@ -369,8 +228,7 @@ class _GroupPageState extends State child: Column( children: [ Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( fit: FlexFit.tight, @@ -380,32 +238,21 @@ class _GroupPageState extends State left: 20, top: 20, ), - child: destination == - 'New Delhi Railway Station' || - destination == - 'Hazrat Nizamuddin Railway Station' + child: destination == 'New Delhi Railway Station' || destination == 'Hazrat Nizamuddin Railway Station' ? Icon( Icons.train, - color: - getVisibleIconColorOnScaffold( - context), + color: getVisibleIconColorOnScaffold(context), size: 30, ) - : destination == - 'Indira Gandhi International Airport' + : destination == 'Indira Gandhi International Airport' ? Icon( - Icons - .airplanemode_active, - color: - getVisibleIconColorOnScaffold( - context), + Icons.airplanemode_active, + color: getVisibleIconColorOnScaffold(context), size: 30, ) : Icon( Icons.directions_bus, - color: - getVisibleIconColorOnScaffold( - context), + color: getVisibleIconColorOnScaffold(context), size: 30, )), ), @@ -413,8 +260,7 @@ class _GroupPageState extends State fit: FlexFit.tight, flex: 4, child: Padding( - padding: const EdgeInsets.only( - top: 10.0), + padding: const EdgeInsets.only(top: 10.0), child: Text( destination, style: TextStyle( @@ -433,34 +279,22 @@ class _GroupPageState extends State top: 10, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, children: [ - Text( - 'Press here to edit the details: '), + Text('Press here to edit the details: '), TextButton.icon( onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - EditGroup( - groupUID: - groupUID))); + Navigator.push(context, MaterialPageRoute(builder: (context) => EditGroup(groupUID: groupUID))); }, icon: Icon( FontAwesomeIcons.pen, size: 16.0, - color: - getVisibleTextColorOnScaffold( - context), + color: getVisibleTextColorOnScaffold(context), ), label: Text( 'Edit', style: TextStyle( - color: - getVisibleTextColorOnScaffold( - context), + color: getVisibleTextColorOnScaffold(context), ), )), ], @@ -471,15 +305,11 @@ class _GroupPageState extends State top: 10, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '*Contact group admin to edit details.', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), ], ), @@ -490,8 +320,7 @@ class _GroupPageState extends State top: 10, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Start : $start', @@ -507,8 +336,7 @@ class _GroupPageState extends State bottom: 5, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'End: $end', @@ -524,8 +352,7 @@ class _GroupPageState extends State bottom: 5, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Number of members in group: $presentNum', @@ -541,8 +368,7 @@ class _GroupPageState extends State bottom: 5, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Max number of poolers: $maxPoolers', @@ -555,33 +381,20 @@ class _GroupPageState extends State ), Container( child: StreamBuilder( - stream: FirebaseFirestore.instance - .collection('group') - .doc(groupUID) - .collection('users') - .snapshots(), + stream: FirebaseFirestore.instance.collection('group').doc(groupUID).collection('users').snapshots(), builder: (_, snapshots) { if (!snapshots.hasData) { return Center( - child: - CircularProgressIndicator(), + child: CircularProgressIndicator(), ); } return ListView.builder( shrinkWrap: true, - itemCount: snapshots.data == null - ? 0 - : snapshots.data.docs.length, + itemCount: snapshots.data == null ? 0 : snapshots.data.docs.length, itemBuilder: (ctx, index) { - var cancelledRides = snapshots - .data.docs[index] - .data()['cancelledrides']; - var totalRides = snapshots - .data.docs[index] - .data()['totalrides']; - userRating = 5 - - (0.2 * cancelledRides) + - (0.35 * totalRides); + var cancelledRides = snapshots.data.docs[index].data()['cancelledrides']; + var totalRides = snapshots.data.docs[index].data()['totalrides']; + userRating = 5 - (0.2 * cancelledRides) + (0.35 * totalRides); if (userRating < 0) { userRating = 0; } @@ -589,154 +402,81 @@ class _GroupPageState extends State userRating = 5; } return Card( - color: Theme.of(context) - .scaffoldBackgroundColor, + color: Theme.of(context).scaffoldBackgroundColor, child: ListTile( - title: Text(snapshots - .data.docs[index] - .data()['name']), + title: Text(snapshots.data.docs[index].data()['name']), subtitle: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - 'Hostel: ${snapshots.data.docs[index].data()['hostel']}'), + Text('Hostel: ${snapshots.data.docs[index].data()['hostel']}'), GestureDetector( onTap: () async { try { - if (Platform - .isIOS) { - await Clipboard.setData( - ClipboardData( - text: - '${snapshots.data.docs[index].data()['mobilenum']}')) - .then( - (result) { - final snackBar = - SnackBar( - backgroundColor: - Theme.of(context) - .primaryColor, - content: - Text( + if (Platform.isIOS) { + await Clipboard.setData(ClipboardData(text: '${snapshots.data.docs[index].data()['mobilenum']}')).then((result) { + final snackBar = SnackBar( + backgroundColor: Theme.of(context).primaryColor, + content: Text( 'Copied to Clipboard', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), - duration: Duration( - seconds: - 1), + duration: Duration(seconds: 1), ); - ScaffoldMessenger.of( - context) - .hideCurrentSnackBar(); - ScaffoldMessenger.of( - context) - .showSnackBar( - snackBar); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(snackBar); }); } else { - await launch( - 'tel://${snapshots.data.docs[index].data()['mobilenum']}'); + await launch('tel://${snapshots.data.docs[index].data()['mobilenum']}'); } } catch (e) { - await Clipboard.setData( - ClipboardData( - text: - '${snapshots.data.docs[index].data()['mobilenum']}')) - .then( - (result) { - final snackBar = - SnackBar( - backgroundColor: - Theme.of( - context) - .primaryColor, + await Clipboard.setData(ClipboardData(text: '${snapshots.data.docs[index].data()['mobilenum']}')).then((result) { + final snackBar = SnackBar( + backgroundColor: Theme.of(context).primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), - duration: - Duration( - seconds: - 1), + duration: Duration(seconds: 1), ); - ScaffoldMessenger.of( - context) - .hideCurrentSnackBar(); - ScaffoldMessenger.of( - context) - .showSnackBar( - snackBar); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(snackBar); }); } }, - child: Text( - 'Mobile Number: ${snapshots.data.docs[index].data()['mobilenum']}')), + child: Text('Mobile Number: ${snapshots.data.docs[index].data()['mobilenum']}')), Row( children: [ Text('User Rating:'), Row( - children: < - Widget>[], + children: [], ), - showRating( - userRating), + showRating(userRating), ], ) ], ), - trailing: grpOwner == - snapshots.data - .docs[index].id + trailing: grpOwner == snapshots.data.docs[index].id ? FaIcon( - FontAwesomeIcons - .crown, - color: - getVisibleIconColorOnScaffold( - context), + FontAwesomeIcons.crown, + color: getVisibleIconColorOnScaffold(context), ) - : grpOwner == - currentuser - .uid && - !timestampFlag + : grpOwner == currentuser.uid && !timestampFlag ? IconButton( - icon: Icon(Icons - .exit_to_app), - color: - getVisibleIconColorOnScaffold( - context), - tooltip: - 'Kick User', - onPressed: - () async { + icon: Icon(Icons.exit_to_app), + color: getVisibleIconColorOnScaffold(context), + tooltip: 'Kick User', + onPressed: () async { await showDialog( - context: - context, - builder: - (BuildContext - ctx) { + context: context, + builder: (BuildContext ctx) { return AlertDialog( - title: Text( - 'Kick User'), - content: - Text('Are you sure you want to kick this user?'), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(20.0)), - actions: < - Widget>[ + title: Text('Kick User'), + content: Text('Are you sure you want to kick this user?'), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), + actions: [ TextButton( - child: - Text('Kick', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), - onPressed: - () async { + child: Text('Kick', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), + onPressed: () async { Navigator.pop(context); ProgressDialog pr; pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); @@ -758,10 +498,8 @@ class _GroupPageState extends State }, ), TextButton( - child: - Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), - onPressed: - () { + child: Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), + onPressed: () { Navigator.of(context).pop(); }, ), @@ -786,11 +524,7 @@ class _GroupPageState extends State ), floatingActionButton: FloatingActionButton( onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - ChatScreen(groupUID))); + Navigator.push(context, MaterialPageRoute(builder: (context) => ChatScreen(groupUID))); }, child: Stack( alignment: Alignment(-10, -10), @@ -805,8 +539,7 @@ class _GroupPageState extends State ), ); } else { - return Container( - child: Center(child: CircularProgressIndicator())); + return Container(child: Center(child: CircularProgressIndicator())); } }); } else { diff --git a/lib/screens/notifications/services/database.dart b/lib/screens/notifications/services/database.dart index 6d3626d..cba6a20 100644 --- a/lib/screens/notifications/services/database.dart +++ b/lib/screens/notifications/services/database.dart @@ -3,12 +3,9 @@ import 'package:firebase_auth/firebase_auth.dart'; class NotificationDatabase { final _auth = FirebaseAuth.instance; - final CollectionReference> groupdetails = - FirebaseFirestore.instance.collection('group'); - final CollectionReference> userDetails = - FirebaseFirestore.instance.collection('userdetails'); - final CollectionReference> chatLists = - FirebaseFirestore.instance.collection('chatroom'); + final CollectionReference> groupdetails = FirebaseFirestore.instance.collection('group'); + final CollectionReference> userDetails = FirebaseFirestore.instance.collection('userdetails'); + final CollectionReference> chatLists = FirebaseFirestore.instance.collection('chatroom'); //Request created to join a group Future createRequest(String groupId) async { @@ -71,21 +68,12 @@ class NotificationDatabase { var name; var nameo; - await userDetails - .doc(user.uid) - .collection('Notifications') - .doc(notifId) - .update({ + await userDetails.doc(user.uid).collection('Notifications').doc(notifId).update({ 'response': response, }); if (response == true) { - await userDetails - .doc(user.uid) - .collection('Notifications') - .doc(notifId) - .get() - .then((value) { + await userDetails.doc(user.uid).collection('Notifications').doc(notifId).get().then((value) { listuid = value.data()['groupId']; uid = value.data()['from']; }); @@ -114,11 +102,7 @@ class NotificationDatabase { } var request = groupdetails.doc(listuid).collection('users'); - await FirebaseFirestore.instance - .collection('userdetails') - .doc(uid) - .get() - .then((value) async { + await FirebaseFirestore.instance.collection('userdetails').doc(uid).get().then((value) async { if (value.exists) { await request.doc(uid).set({ 'name': value.data()['name'], @@ -174,12 +158,7 @@ class NotificationDatabase { name = value.data()['name']; }); - await userDetails - .doc(user.uid) - .collection('Notifications') - .doc(notifId) - .get() - .then((value) { + await userDetails.doc(user.uid).collection('Notifications').doc(notifId).get().then((value) { listuid = value.data()['groupId']; uid = value.data()['from']; }); @@ -218,8 +197,7 @@ class NotificationDatabase { } //Deleting a notification - Future remNotif( - String notifId, var purpose, var uid, var response) async { + Future remNotif(String notifId, var purpose, var uid, var response) async { final user = _auth.currentUser; if (purpose == 'Request to Join' && response == false) { var name; @@ -229,12 +207,7 @@ class NotificationDatabase { name = value.data()['name']; }); - await userDetails - .doc(user.uid) - .collection('Notifications') - .doc(notifId) - .get() - .then((value) { + await userDetails.doc(user.uid).collection('Notifications').doc(notifId).get().then((value) { listuid = value.data()['groupId']; }); @@ -247,20 +220,14 @@ class NotificationDatabase { 'groupId': listuid, }); } - await userDetails - .doc(user.uid) - .collection('Notifications') - .doc(notifId) - .delete(); + await userDetails.doc(user.uid).collection('Notifications').doc(notifId).delete(); } Future removeAllNotif() async { final user = _auth.currentUser; - final notifs = - await userDetails.doc(user.uid).collection('Notifications').get(); + final notifs = await userDetails.doc(user.uid).collection('Notifications').get(); for (var i = 0; i < notifs.docs.length; i++) { - if (notifs.docs[i].data()['response'] == null && - notifs.docs[i].data()['purpose'] == 'Request to Join') { + if (notifs.docs[i].data()['response'] == null && notifs.docs[i].data()['purpose'] == 'Request to Join') { var name; var listuid; @@ -268,10 +235,7 @@ class NotificationDatabase { name = value.data()['name']; }); listuid = notifs.docs[i].id; - await userDetails - .doc(notifs.docs[i].data()['from']) - .collection('Notifications') - .add({ + await userDetails.doc(notifs.docs[i].data()['from']).collection('Notifications').add({ 'from': user.uid, 'senderName': name, 'createdAt': Timestamp.now(), @@ -280,11 +244,7 @@ class NotificationDatabase { 'groupId': listuid, }); } - await userDetails - .doc(user.uid) - .collection('Notifications') - .doc(notifs.docs[i].id) - .delete(); + await userDetails.doc(user.uid).collection('Notifications').doc(notifs.docs[i].id).delete(); } } } diff --git a/lib/screens/notifications/widgets/notifslist.dart b/lib/screens/notifications/widgets/notifslist.dart index 2eb753c..4779272 100644 --- a/lib/screens/notifications/widgets/notifslist.dart +++ b/lib/screens/notifications/widgets/notifslist.dart @@ -15,19 +15,12 @@ class NotifsList extends StatefulWidget { class _NotifsListState extends State { final NotifServices _notifServices = NotifServices(); - Future getUserDetails( - String uid, String purpose, String notifId, var response) async { + Future getUserDetails(String uid, String purpose, String notifId, var response) async { var currentGroup; - await FirebaseFirestore.instance - .collection('userdetails') - .doc(uid) - .get() - .then((value) { + await FirebaseFirestore.instance.collection('userdetails').doc(uid).get().then((value) { currentGroup = value.data()['currentGroup']; }); - if (currentGroup != null && - purpose == 'Request to Join' && - response == null) { + if (currentGroup != null && purpose == 'Request to Join' && response == null) { await _notifServices.removeNotif(notifId, purpose, uid, response); return null; } @@ -38,12 +31,7 @@ class _NotifsListState extends State { Widget build(BuildContext context) { final user = Provider.of(context); return StreamBuilder( - stream: FirebaseFirestore.instance - .collection('userdetails') - .doc(user.uid) - .collection('Notifications') - .orderBy('createdAt', descending: true) - .snapshots(), + stream: FirebaseFirestore.instance.collection('userdetails').doc(user.uid).collection('Notifications').orderBy('createdAt', descending: true).snapshots(), builder: (ctx, futureSnapshot) { if (futureSnapshot.connectionState == ConnectionState.waiting) { return Center( @@ -51,14 +39,12 @@ class _NotifsListState extends State { ); } return ListView.builder( - itemCount: - futureSnapshot.data == null ? 0 : futureSnapshot.data.docs.length, + itemCount: futureSnapshot.data == null ? 0 : futureSnapshot.data.docs.length, itemBuilder: (context, index) { final docId = futureSnapshot.data.docs[index].id; final fromuid = futureSnapshot.data.docs[index].data()['from']; final name = futureSnapshot.data.docs[index].data()['senderName']; - final createdAt = - futureSnapshot.data.docs[index].data()['createdAt']; + final createdAt = futureSnapshot.data.docs[index].data()['createdAt']; final response = futureSnapshot.data.docs[index].data()['response']; final purpose = futureSnapshot.data.docs[index].data()['purpose']; return FutureBuilder( @@ -66,8 +52,7 @@ class _NotifsListState extends State { builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) {} if (snapshot != null) { - return NotifTile( - docId, fromuid, name, createdAt, response, purpose); + return NotifTile(docId, fromuid, name, createdAt, response, purpose); } return null; }); diff --git a/lib/screens/profile/userprofile.dart b/lib/screens/profile/userprofile.dart index 6a86eb2..8b01a51 100644 --- a/lib/screens/profile/userprofile.dart +++ b/lib/screens/profile/userprofile.dart @@ -19,8 +19,7 @@ class MyProfile extends StatefulWidget { _MyProfileState createState() => _MyProfileState(); } -class _MyProfileState extends State - with AutomaticKeepAliveClientMixin { +class _MyProfileState extends State with AutomaticKeepAliveClientMixin { User currentUser; var namefirst = 'P'; final GlobalKey scaffoldKey = GlobalKey(); @@ -69,8 +68,7 @@ class _MyProfileState extends State return WillPopScope( onWillPop: () { Navigator.pop(context); - Navigator.push( - context, MaterialPageRoute(builder: (context) => RootScreen())); + Navigator.push(context, MaterialPageRoute(builder: (context) => RootScreen())); return Future.value(false); }, child: Scaffold( @@ -82,18 +80,14 @@ class _MyProfileState extends State elevation: 0, actions: [ TextButton.icon( - style: TextButton.styleFrom( - textStyle: TextStyle( - color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), onPressed: () { Navigator.pushNamed(context, '/edituserdetails'); }, icon: Icon(Icons.edit), label: Text('Edit')), TextButton.icon( - style: TextButton.styleFrom( - textStyle: - TextStyle(color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: () async { await showDialog( @@ -102,55 +96,34 @@ class _MyProfileState extends State return AlertDialog( title: Text('Log out'), content: Text('Are you sure you want to log out?'), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20.0)), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), actions: [ TextButton( - child: Text('Log out', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary)), + child: Text('Log out', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, - type: ProgressDialogType.Normal, - isDismissible: false, - showLogs: false); + pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); pr.style( message: 'Logging out...', - backgroundColor: - Theme.of(context).backgroundColor, - messageTextStyle: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + backgroundColor: Theme.of(context).backgroundColor, + messageTextStyle: TextStyle(color: Theme.of(context).colorScheme.secondary), ); await pr.show(); - await Future.delayed(Duration( - seconds: - 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p + await Future.delayed(Duration(seconds: 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p try { await widget._auth.signOut(); await pr.hide(); } catch (err) { await pr.hide(); String errStr = err.message ?? err.toString(); - final snackBar = SnackBar( - content: Text(errStr), - duration: Duration(seconds: 3)); - ScaffoldMessenger.of(context) - .showSnackBar(snackBar); + final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); + ScaffoldMessenger.of(context).showSnackBar(snackBar); } Navigator.of(context).pop(); }, ), TextButton( - child: Text('Cancel', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary)), + child: Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -164,10 +137,7 @@ class _MyProfileState extends State ], ), body: StreamBuilder( - stream: FirebaseFirestore.instance - .collection('userdetails') - .doc(currentuser.uid) - .snapshots(), + stream: FirebaseFirestore.instance.collection('userdetails').doc(currentuser.uid).snapshots(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.active) { name = snapshot.data()['name']; @@ -202,26 +172,22 @@ class _MyProfileState extends State alignment: Alignment.center, children: [ Container( - height: - MediaQuery.of(context).size.height / 6, + height: MediaQuery.of(context).size.height / 6, width: MediaQuery.of(context).size.width, color: Theme.of(context).primaryColor, ), Positioned( - top: MediaQuery.of(context).size.height / 6 - - 74, + top: MediaQuery.of(context).size.height / 6 - 74, child: CircleAvatar( radius: 50, - backgroundColor: - Theme.of(context).colorScheme.secondary, + backgroundColor: Theme.of(context).colorScheme.secondary, child: Text( namefirst.toUpperCase(), style: TextStyle( fontSize: 48, fontFamily: 'Poiret', fontWeight: FontWeight.bold, - color: getVisibleColorOnAccentColor( - context), + color: getVisibleColorOnAccentColor(context), ), ), ), @@ -229,8 +195,7 @@ class _MyProfileState extends State ], ), Container( - margin: EdgeInsets.only( - top: 50, bottom: 20, right: 20, left: 20), + margin: EdgeInsets.only(top: 50, bottom: 20, right: 20, left: 20), child: Center( child: FittedBox( child: SelectableText( @@ -242,11 +207,9 @@ class _MyProfileState extends State ), )), Container( - margin: EdgeInsets.symmetric( - horizontal: 40, vertical: 20), + margin: EdgeInsets.symmetric(horizontal: 40, vertical: 20), child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: ListTile( @@ -254,9 +217,7 @@ class _MyProfileState extends State title: Center( child: Text( 'HOSTEL', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 20), ), ), subtitle: Center( @@ -273,9 +234,7 @@ class _MyProfileState extends State title: Center( child: Text( 'GENDER', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 20), ), ), subtitle: Center( @@ -290,11 +249,9 @@ class _MyProfileState extends State ), ), Container( - margin: EdgeInsets.symmetric( - horizontal: 30, vertical: 20), + margin: EdgeInsets.symmetric(horizontal: 30, vertical: 20), child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: ListTile( @@ -303,9 +260,7 @@ class _MyProfileState extends State child: Text( 'TOTAL RIDES', textAlign: TextAlign.center, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 18), + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), ), ), subtitle: Center( @@ -323,9 +278,7 @@ class _MyProfileState extends State child: Text( 'CANCELLED TRIPS', textAlign: TextAlign.center, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 18), + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), ), ), subtitle: Center( @@ -338,65 +291,42 @@ class _MyProfileState extends State ), ), Container( - margin: EdgeInsets.symmetric( - horizontal: 30, vertical: 20), + margin: EdgeInsets.symmetric(horizontal: 30, vertical: 20), child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: ListTile( onTap: () async { try { if (Platform.isIOS) { - await Clipboard.setData( - ClipboardData( - text: '$mobilenum')) - .then((result) { + await Clipboard.setData(ClipboardData(text: '$mobilenum')).then((result) { final snackBar = SnackBar( - backgroundColor: - Theme.of(context) - .primaryColor, + backgroundColor: Theme.of(context).primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), - duration: - Duration(seconds: 1), + duration: Duration(seconds: 1), ); - ScaffoldMessenger.of(context) - .hideCurrentSnackBar(); - ScaffoldMessenger.of(context) - .showSnackBar(snackBar); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(snackBar); }); } else { await launch('tel://$mobilenum'); } } catch (e) { - await Clipboard.setData( - ClipboardData( - text: '$mobilenum')) - .then((result) { + await Clipboard.setData(ClipboardData(text: '$mobilenum')).then((result) { final snackBar = SnackBar( - backgroundColor: - Theme.of(context) - .primaryColor, + backgroundColor: Theme.of(context).primaryColor, content: Text( 'Copied to Clipboard', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), duration: Duration(seconds: 1), ); - ScaffoldMessenger.of(context) - .hideCurrentSnackBar(); - ScaffoldMessenger.of(context) - .showSnackBar(snackBar); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(snackBar); }); } }, @@ -404,9 +334,7 @@ class _MyProfileState extends State child: Text( 'MOBILE NUMBER', textAlign: TextAlign.center, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 18), + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), ), ), subtitle: Center( @@ -423,9 +351,7 @@ class _MyProfileState extends State child: Text( 'USER RATING', textAlign: TextAlign.center, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 18), + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), ), ), subtitle: Center( @@ -439,8 +365,7 @@ class _MyProfileState extends State ), ), Container( - margin: EdgeInsets.symmetric( - horizontal: 30, vertical: 20), + margin: EdgeInsets.symmetric(horizontal: 30, vertical: 20), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -450,9 +375,7 @@ class _MyProfileState extends State title: Center( child: Text( 'EMAIL ID', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 18), + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18), ), ), subtitle: Center( diff --git a/lib/screens/requests/myrequests.dart b/lib/screens/requests/myrequests.dart index a6e249c..9054efa 100644 --- a/lib/screens/requests/myrequests.dart +++ b/lib/screens/requests/myrequests.dart @@ -11,17 +11,12 @@ class MyRequests extends StatefulWidget { _MyRequestsState createState() => _MyRequestsState(); } -class _MyRequestsState extends State - with AutomaticKeepAliveClientMixin { +class _MyRequestsState extends State with AutomaticKeepAliveClientMixin { final FirebaseAuth auth = FirebaseAuth.instance; Future getOldTrips() async { var user = auth.currentUser; final userid = user.uid; - var qn = await FirebaseFirestore.instance - .collection('group') - .where('users', arrayContains: userid) - .orderBy('end', descending: true) - .get(); + var qn = await FirebaseFirestore.instance.collection('group').where('users', arrayContains: userid).orderBy('end', descending: true).get(); return qn.docs; } @@ -32,8 +27,7 @@ class _MyRequestsState extends State return WillPopScope( onWillPop: () { Navigator.pop(context); - Navigator.push( - context, MaterialPageRoute(builder: (context) => RootScreen())); + Navigator.push(context, MaterialPageRoute(builder: (context) => RootScreen())); return Future.value(false); }, child: Scaffold( @@ -42,10 +36,7 @@ class _MyRequestsState extends State ), body: Container( child: StreamBuilder( - stream: FirebaseFirestore.instance - .collection('userdetails') - .doc(currentuser.uid) - .snapshots(), + stream: FirebaseFirestore.instance.collection('userdetails').doc(currentuser.uid).snapshots(), builder: (context, usersnapshot) { return FutureBuilder( future: getOldTrips(), @@ -56,129 +47,74 @@ class _MyRequestsState extends State ); } else { return ListView.builder( - itemCount: snapshot.data == null - ? 0 - : snapshot.data.length, + itemCount: snapshot.data == null ? 0 : snapshot.data.length, itemBuilder: (ctx, index) { - final destination = - snapshot.data()[index].data()['destination']; - final start = snapshot - .data()[index] - .data()['start'] - .toDate(); - final end = - snapshot.data()[index].data()['end'].toDate(); + final destination = snapshot.data()[index].data()['destination']; + final start = snapshot.data()[index].data()['start'].toDate(); + final end = snapshot.data()[index].data()['end'].toDate(); final docId = snapshot.data()[index].id; - final privacy = - snapshot.data()[index].data()['privacy']; - final numberOfMembers = snapshot - .data()[index] - .data()['numberOfMembers']; + final privacy = snapshot.data()[index].data()['privacy']; + final numberOfMembers = snapshot.data()[index].data()['numberOfMembers']; final data = snapshot.data()[index]; return Hero( tag: Text(docId), - child: (docId != - usersnapshot.data()['currentGroup']) + child: (docId != usersnapshot.data()['currentGroup']) ? Card( - color: Theme.of(context) - .scaffoldBackgroundColor, + color: Theme.of(context).scaffoldBackgroundColor, elevation: 0.0, child: InkWell( onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - EndedGroupDetails( - destination, - docId, - privacy, - start, - end, - numberOfMembers, - data))); + Navigator.push(context, MaterialPageRoute(builder: (context) => EndedGroupDetails(destination, docId, privacy, start, end, numberOfMembers, data))); }, child: Card( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(25.0))), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(25.0))), elevation: 5, - margin: EdgeInsets.symmetric( - vertical: 6, horizontal: 5), + margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), child: Container( child: SingleChildScrollView( child: Column( children: [ Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( fit: FlexFit.tight, flex: 1, child: Container( - margin: EdgeInsets - .only( + margin: EdgeInsets.only( left: 20, top: 20, ), - child: snapshot.data()[index].data()[ - 'destination'] == - 'New Delhi Railway Station' || - snapshot.data()[index].data()[ - 'destination'] == - 'Hazrat Nizamuddin Railway Station' + child: snapshot.data()[index].data()['destination'] == 'New Delhi Railway Station' || snapshot.data()[index].data()['destination'] == 'Hazrat Nizamuddin Railway Station' ? Icon( - Icons - .train, - color: Theme.of( - context) - .colorScheme - .secondary, + Icons.train, + color: Theme.of(context).colorScheme.secondary, size: 30, ) - : snapshot.data()[index].data()[ - 'destination'] == - 'Indira Gandhi International Airport' + : snapshot.data()[index].data()['destination'] == 'Indira Gandhi International Airport' ? Icon( - Icons - .airplanemode_active, - color: Theme.of(context) - .colorScheme - .secondary, - size: - 30, + Icons.airplanemode_active, + color: Theme.of(context).colorScheme.secondary, + size: 30, ) : Icon( - Icons - .directions_bus, - color: Theme.of(context) - .colorScheme - .secondary, - size: - 30, + Icons.directions_bus, + color: Theme.of(context).colorScheme.secondary, + size: 30, )), ), Flexible( fit: FlexFit.tight, flex: 4, child: Padding( - padding: - const EdgeInsets - .only( - top: 10.0), + padding: const EdgeInsets.only(top: 10.0), child: Text( '${snapshot.data()[index].data()['destination']}', style: TextStyle( fontSize: 17, - fontWeight: - FontWeight - .bold, + fontWeight: FontWeight.bold, ), - textAlign: - TextAlign - .center, + textAlign: TextAlign.center, ), ), ), @@ -190,9 +126,7 @@ class _MyRequestsState extends State top: 10, ), child: Row( - mainAxisAlignment: - MainAxisAlignment - .center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Started : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data()[index].data()['start'].toDate())}', @@ -208,9 +142,7 @@ class _MyRequestsState extends State bottom: 5, ), child: Row( - mainAxisAlignment: - MainAxisAlignment - .center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Ended : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data()[index].data()['end'].toDate())}', @@ -222,19 +154,12 @@ class _MyRequestsState extends State ), ), Padding( - padding: - const EdgeInsets.all( - 8.0), + padding: const EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( - children: [ - Text( - 'Number of poolers: ${snapshot.data()[index].data()['numberOfMembers'].toString()}') - ], + children: [Text('Number of poolers: ${snapshot.data()[index].data()['numberOfMembers'].toString()}')], ), ], ), diff --git a/lib/screens/rootscreen.dart b/lib/screens/rootscreen.dart index 57aceb3..0c23e5e 100644 --- a/lib/screens/rootscreen.dart +++ b/lib/screens/rootscreen.dart @@ -32,9 +32,7 @@ class _RootScreenState extends State { child: Icon( Icons.home, size: 20.0, - color: _selectedPage == 0 - ? Theme.of(context).colorScheme.secondary - : Colors.white, + color: _selectedPage == 0 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -42,9 +40,7 @@ class _RootScreenState extends State { child: Icon( Icons.format_list_bulleted, size: 20.0, - color: _selectedPage == 1 - ? Theme.of(context).colorScheme.secondary - : Colors.white, + color: _selectedPage == 1 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -52,9 +48,7 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 2 ? Icons.chat_bubble : Icons.chat_bubble_outline, size: 20.0, - color: _selectedPage == 2 - ? Theme.of(context).colorScheme.secondary - : Colors.white, + color: _selectedPage == 2 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -62,9 +56,7 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 3 ? Icons.notifications : Icons.notifications_none, size: 20.0, - color: _selectedPage == 3 - ? Theme.of(context).colorScheme.secondary - : Colors.white, + color: _selectedPage == 3 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), Tooltip( @@ -72,9 +64,7 @@ class _RootScreenState extends State { child: Icon( _selectedPage == 4 ? Icons.person : Icons.person_outline, size: 20.0, - color: _selectedPage == 4 - ? Theme.of(context).colorScheme.secondary - : Colors.white, + color: _selectedPage == 4 ? Theme.of(context).colorScheme.secondary : Colors.white, ), ), ]; @@ -115,8 +105,7 @@ class _RootScreenState extends State { void bottomTapped(int index) { setState(() { _selectedPage = index; - pageController.animateToPage(index, - duration: Duration(milliseconds: 200), curve: Curves.bounceInOut); + pageController.animateToPage(index, duration: Duration(milliseconds: 200), curve: Curves.bounceInOut); }); } diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index e5c45bb..1ebb62b 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -96,9 +96,7 @@ class _SettingsState extends State { actions: [ user != null ? TextButton.icon( - style: TextButton.styleFrom( - textStyle: TextStyle( - color: getVisibleColorOnPrimaryColor(context))), + style: TextButton.styleFrom(textStyle: TextStyle(color: getVisibleColorOnPrimaryColor(context))), icon: Icon(FontAwesomeIcons.signOutAlt), onPressed: () async { await showDialog( @@ -107,57 +105,35 @@ class _SettingsState extends State { return AlertDialog( title: Text('Log out'), content: Text('Are you sure you want to log out?'), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20.0)), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), actions: [ TextButton( - child: Text('Log out', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary)), + child: Text('Log out', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () async { ProgressDialog pr; - pr = ProgressDialog(context, - type: ProgressDialogType.Normal, - isDismissible: false, - showLogs: false); + pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false); pr.style( message: 'Logging out...', - backgroundColor: - Theme.of(context).backgroundColor, - messageTextStyle: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary), + backgroundColor: Theme.of(context).backgroundColor, + messageTextStyle: TextStyle(color: Theme.of(context).colorScheme.secondary), ); await pr.show(); - await Future.delayed(Duration( - seconds: - 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p + await Future.delayed(Duration(seconds: 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p try { await widget._auth.signOut(); await pr.hide(); } catch (err) { await pr.hide(); - String errStr = - err.message ?? err.toString(); - final snackBar = SnackBar( - content: Text(errStr), - duration: Duration(seconds: 3)); - ScaffoldMessenger.of(context) - .showSnackBar(snackBar); + String errStr = err.message ?? err.toString(); + final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3)); + ScaffoldMessenger.of(context).showSnackBar(snackBar); } Navigator.of(context).pop(); Navigator.of(context).pop(); }, ), TextButton( - child: Text('Cancel', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .secondary)), + child: Text('Cancel', style: TextStyle(color: Theme.of(context).colorScheme.secondary)), onPressed: () { Navigator.of(context).pop(); }, @@ -195,9 +171,7 @@ class _SettingsState extends State { color: Theme.of(context).colorScheme.secondary, ), iconSize: 30, - style: TextStyle( - color: getVisibleColorOnScaffold(context), - fontSize: 15), + style: TextStyle(color: getVisibleColorOnScaffold(context), fontSize: 15), underline: Container( height: 2, color: Theme.of(context).colorScheme.secondary, @@ -214,20 +188,13 @@ class _SettingsState extends State { newValueSelected != 'system' ? setState(() { _theme = newValueSelected; - _darkTheme = - newValueSelected == 'dark' ? true : false; - newValueSelected == 'dark' - ? onThemeChanged(true, themeNotifier) - : onThemeChanged(false, themeNotifier); + _darkTheme = newValueSelected == 'dark' ? true : false; + newValueSelected == 'dark' ? onThemeChanged(true, themeNotifier) : onThemeChanged(false, themeNotifier); }) : setState(() { _theme = newValueSelected; - brightness == Brightness.dark - ? _darkTheme = true - : _darkTheme = false; - brightness == Brightness.dark - ? onThemeChanged(true, themeNotifier) - : onThemeChanged(false, themeNotifier); + brightness == Brightness.dark ? _darkTheme = true : _darkTheme = false; + brightness == Brightness.dark ? onThemeChanged(true, themeNotifier) : onThemeChanged(false, themeNotifier); }); setTheme(newValueSelected); }, @@ -270,14 +237,10 @@ class _SettingsState extends State { height: w * 0.10, child: GestureDetector( child: AnimatedContainer( - margin: const EdgeInsets.symmetric( - horizontal: 3), + margin: const EdgeInsets.symmetric(horizontal: 3), decoration: BoxDecoration( color: colorList[index].color, - borderRadius: BorderRadius.circular( - _selectedIndex == index - ? w * 0.05 - : 0), + borderRadius: BorderRadius.circular(_selectedIndex == index ? w * 0.05 : 0), ), duration: Duration(milliseconds: 300), child: _selectedIndex == index @@ -291,8 +254,7 @@ class _SettingsState extends State { setState(() { _selectedIndex = index; }); - onColorChanged(colorList[index].value, - colorList[index].color, themeNotifier); + onColorChanged(colorList[index].value, colorList[index].color, themeNotifier); }), ); }), @@ -311,12 +273,10 @@ class _SettingsState extends State { padding: const EdgeInsets.only(left: 12.0, right: 12.0), child: Card( elevation: 0, - shape: BeveledRectangleBorder( - borderRadius: BorderRadius.circular(0)), + shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(0)), child: ListTile( onTap: () { - launch( - 'https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); + launch('https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); }, title: Text( 'Bug Report', @@ -335,8 +295,7 @@ class _SettingsState extends State { color: getVisibleTextColorOnScaffold(context), ), onPressed: () { - launch( - 'https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); + launch('https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser'); }, ), ), @@ -349,14 +308,12 @@ class _SettingsState extends State { } void onThemeChanged(bool value, ThemeNotifier themeNotifier) async { - themeNotifier.setTheme(getThemeDataForAccentColor( - Theme.of(context).colorScheme.secondary, value)); + themeNotifier.setTheme(getThemeDataForAccentColor(Theme.of(context).colorScheme.secondary, value)); var prefs = await SharedPreferences.getInstance(); await prefs.setBool('darkMode', value); } - void onColorChanged( - String value, Color accentColor, ThemeNotifier themeNotifier) async { + void onColorChanged(String value, Color accentColor, ThemeNotifier themeNotifier) async { themeNotifier.setTheme(getThemeDataForAccentColor(accentColor, _darkTheme)); var prefs = await SharedPreferences.getInstance(); await prefs.setString('accentColor', value); @@ -437,13 +394,11 @@ class PreviewWidgetState extends State { ), ElevatedButton( style: ButtonStyle( - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.secondary), + foregroundColor: MaterialStateProperty.all(Theme.of(context).colorScheme.secondary), ), child: Text( 'BUTTON', - style: - TextStyle(color: getVisibleColorOnAccentColor(context)), + style: TextStyle(color: getVisibleColorOnAccentColor(context)), ), onPressed: () {}, ) diff --git a/lib/screens/tripslist.dart b/lib/screens/tripslist.dart index 110dd39..558124b 100644 --- a/lib/screens/tripslist.dart +++ b/lib/screens/tripslist.dart @@ -15,14 +15,12 @@ class TripsList extends StatefulWidget { final _notPrivate; final _selectedDestination; final Function startCreatingTrip; - TripsList(this._dest, this._selectedDestination, this._notPrivate, - {this.inGroupFetch, this.inGroup, this.startCreatingTrip}); + TripsList(this._dest, this._selectedDestination, this._notPrivate, {this.inGroupFetch, this.inGroup, this.startCreatingTrip}); @override _TripsListState createState() => _TripsListState(); } -class _TripsListState extends State - with SingleTickerProviderStateMixin { +class _TripsListState extends State with SingleTickerProviderStateMixin { final ScrollController _controller = ScrollController(); AnimationController _hideFabController; bool flag; @@ -43,10 +41,7 @@ class _TripsListState extends State final currentuser = Provider.of(context); return Scaffold( body: StreamBuilder( - stream: FirebaseFirestore.instance - .collection('userdetails') - .doc(currentuser.uid) - .snapshots(), + stream: FirebaseFirestore.instance.collection('userdetails').doc(currentuser.uid).snapshots(), builder: (_, usersnapshot) { if (usersnapshot.connectionState == ConnectionState.waiting) { Center(child: CircularProgressIndicator()); @@ -74,34 +69,12 @@ class _TripsListState extends State return Container( child: StreamBuilder( stream: widget._dest == true && widget._notPrivate == true - ? FirebaseFirestore.instance - .collection('group') - .where('end', isGreaterThan: Timestamp.now()) - .where('destination', - isEqualTo: widget._selectedDestination) - .where('privacy', isEqualTo: false.toString()) - .orderBy('end', descending: true) - .snapshots() + ? FirebaseFirestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).where('destination', isEqualTo: widget._selectedDestination).where('privacy', isEqualTo: false.toString()).orderBy('end', descending: true).snapshots() : widget._dest == true - ? FirebaseFirestore.instance - .collection('group') - .where('end', isGreaterThan: Timestamp.now()) - .where('destination', - isEqualTo: widget._selectedDestination) - .orderBy('end', descending: true) - .snapshots() + ? FirebaseFirestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).where('destination', isEqualTo: widget._selectedDestination).orderBy('end', descending: true).snapshots() : widget._notPrivate == true - ? FirebaseFirestore.instance - .collection('group') - .where('end', isGreaterThan: Timestamp.now()) - .where('privacy', isEqualTo: false.toString()) - .orderBy('end', descending: true) - .snapshots() - : FirebaseFirestore.instance - .collection('group') - .where('end', isGreaterThan: Timestamp.now()) - .orderBy('end', descending: true) - .snapshots(), + ? FirebaseFirestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).where('privacy', isEqualTo: false.toString()).orderBy('end', descending: true).snapshots() + : FirebaseFirestore.instance.collection('group').where('end', isGreaterThan: Timestamp.now()).orderBy('end', descending: true).snapshots(), builder: (_, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { Center(child: CircularProgressIndicator()); @@ -110,22 +83,14 @@ class _TripsListState extends State return ListView.builder( controller: _controller, physics: BouncingScrollPhysics(), - itemCount: snapshot.data == null - ? 0 - : snapshot.data.docs.length, + itemCount: snapshot.data == null ? 0 : snapshot.data.docs.length, itemBuilder: (ctx, index) { - final destination = - snapshot.data.docs[index].data()['destination']; - final start = snapshot.data.docs[index] - .data()['start'] - .toDate(); - final end = - snapshot.data.docs[index].data()['end'].toDate(); + final destination = snapshot.data.docs[index].data()['destination']; + final start = snapshot.data.docs[index].data()['start'].toDate(); + final end = snapshot.data.docs[index].data()['end'].toDate(); final docId = snapshot.data.docs[index].id; - final privacy = - snapshot.data.docs[index].data()['privacy']; - final numberOfMembers = snapshot.data.docs[index] - .data()['numberOfMembers']; + final privacy = snapshot.data.docs[index].data()['privacy']; + final numberOfMembers = snapshot.data.docs[index].data()['numberOfMembers']; final data = snapshot.data.docs[index]; if (docId == usersnapshot.data()['currentGroup']) { flag = true; @@ -139,51 +104,30 @@ class _TripsListState extends State elevation: 0.0, child: InkWell( onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => GroupDetails( - destination, - docId, - privacy, - start, - end, - numberOfMembers, - data))); + Navigator.push(context, MaterialPageRoute(builder: (context) => GroupDetails(destination, docId, privacy, start, end, numberOfMembers, data))); }, child: Card( shape: flag ? RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(25.0)), - side: BorderSide( - color: Theme.of(context) - .colorScheme - .secondary, - width: 2.0), + borderRadius: BorderRadius.all(Radius.circular(25.0)), + side: BorderSide(color: Theme.of(context).colorScheme.secondary, width: 2.0), ) : requestsArray.contains(docId) ? RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(25.0)), - side: BorderSide( - color: Colors.pink[300], - width: 2.0), + borderRadius: BorderRadius.all(Radius.circular(25.0)), + side: BorderSide(color: Colors.pink[300], width: 2.0), ) : RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(25.0)), + borderRadius: BorderRadius.all(Radius.circular(25.0)), ), elevation: 5, - margin: EdgeInsets.symmetric( - vertical: 6, horizontal: 5), + margin: EdgeInsets.symmetric(vertical: 6, horizontal: 5), child: Container( child: SingleChildScrollView( child: Column( children: [ Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( fit: FlexFit.tight, @@ -193,43 +137,21 @@ class _TripsListState extends State left: 20, top: 20, ), - child: snapshot.data.docs[index] - .data()[ - 'destination'] == - 'New Delhi Railway Station' || - snapshot.data - .docs[index] - .data()[ - 'destination'] == - 'Hazrat Nizamuddin Railway Station' + child: snapshot.data.docs[index].data()['destination'] == 'New Delhi Railway Station' || snapshot.data.docs[index].data()['destination'] == 'Hazrat Nizamuddin Railway Station' ? Icon( Icons.train, - color: Theme.of( - context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, size: 30, ) - : snapshot.data.docs[index] - .data()[ - 'destination'] == - 'Indira Gandhi International Airport' + : snapshot.data.docs[index].data()['destination'] == 'Indira Gandhi International Airport' ? Icon( - Icons - .airplanemode_active, - color: Theme.of( - context) - .colorScheme - .secondary, + Icons.airplanemode_active, + color: Theme.of(context).colorScheme.secondary, size: 30, ) : Icon( - Icons - .directions_bus, - color: Theme.of( - context) - .colorScheme - .secondary, + Icons.directions_bus, + color: Theme.of(context).colorScheme.secondary, size: 30, )), ), @@ -237,52 +159,35 @@ class _TripsListState extends State fit: FlexFit.tight, flex: 4, child: Padding( - padding: - const EdgeInsets.only( - top: 10.0), + padding: const EdgeInsets.only(top: 10.0), child: Text( '${snapshot.data.docs[index].data()['destination']}', style: TextStyle( fontSize: 16, - fontWeight: - FontWeight.bold, + fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ), ), - snapshot.data.docs[index] - .data()['privacy'] == - 'true' + snapshot.data.docs[index].data()['privacy'] == 'true' ? Flexible( flex: 2, child: Padding( - padding: - const EdgeInsets - .only( - right: 25.0), + padding: const EdgeInsets.only(right: 25.0), child: Icon( Icons.lock, - color: - Theme.of(context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, ), ), ) : Flexible( flex: 2, child: Padding( - padding: - const EdgeInsets - .only( - right: 25.0), + padding: const EdgeInsets.only(right: 25.0), child: Icon( Icons.lock_open, - color: - Theme.of(context) - .colorScheme - .secondary, + color: Theme.of(context).colorScheme.secondary, ), ), ), @@ -294,8 +199,7 @@ class _TripsListState extends State top: 10, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Start : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data.docs[index].data()['start'].toDate())}', @@ -311,8 +215,7 @@ class _TripsListState extends State bottom: 5, ), child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'End : ${DateFormat('dd.MM.yyyy - kk:mm a').format(snapshot.data.docs[index].data()['end'].toDate())}', @@ -326,18 +229,12 @@ class _TripsListState extends State Container( margin: EdgeInsets.only(bottom: 10), child: Padding( - padding: - const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( - children: [ - Text( - 'Number of members in group: ${snapshot.data.docs[index].data()['numberOfMembers'].toString()}/${snapshot.data.docs[index].data()['maxpoolers'].toString()}') - ], + children: [Text('Number of members in group: ${snapshot.data.docs[index].data()['numberOfMembers'].toString()}/${snapshot.data.docs[index].data()['maxpoolers'].toString()}')], ), ], ), @@ -378,10 +275,7 @@ class _TripsListState extends State padding: const EdgeInsets.fromLTRB(0, 20, 0, 80), child: FloatingActionButton.extended( onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => GroupPage())); + Navigator.push(context, MaterialPageRoute(builder: (context) => GroupPage())); }, icon: Icon(Icons.group), label: Text('Group'), diff --git a/lib/screens/wrapper.dart b/lib/screens/wrapper.dart index 5011b7a..1951c4f 100644 --- a/lib/screens/wrapper.dart +++ b/lib/screens/wrapper.dart @@ -19,9 +19,7 @@ class Wrapper extends StatelessWidget { if (snapshot.connectionState == ConnectionState.waiting) { return Scaffold( body: Center( - child: Container( - height: 200, - child: Image(image: AssetImage('assets/images/logo.png'))), + child: Container(height: 200, child: Image(image: AssetImage('assets/images/logo.png'))), ), backgroundColor: Theme.of(context).primaryColor, ); diff --git a/lib/services/auth.dart b/lib/services/auth.dart index 0732ac4..d632dbd 100644 --- a/lib/services/auth.dart +++ b/lib/services/auth.dart @@ -13,8 +13,7 @@ class AuthService { //sign in with email pass Future signInWithEmailAndPassword(String email, String password) async { - var result = await _auth.signInWithEmailAndPassword( - email: email, password: password); + var result = await _auth.signInWithEmailAndPassword(email: email, password: password); if (result.user.emailVerified) { return true; } else { @@ -29,19 +28,11 @@ class AuthService { // sign up with email pass - Future registerWithEmailAndPassword( - {String email, - String password, - String name, - String mobilenum, - String hostel, - String sex}) async { - var result = await _auth.createUserWithEmailAndPassword( - email: email, password: password); + Future registerWithEmailAndPassword({String email, String password, String name, String mobilenum, String hostel, String sex}) async { + var result = await _auth.createUserWithEmailAndPassword(email: email, password: password); var user = result.user; // creating a new document for user - await DatabaseService(uid: user.uid).enterUserData( - name: name, mobileNumber: mobilenum, hostel: hostel, sex: sex); + await DatabaseService(uid: user.uid).enterUserData(name: name, mobileNumber: mobilenum, hostel: hostel, sex: sex); await result.user.sendEmailVerification(); } diff --git a/lib/services/database.dart b/lib/services/database.dart index a8de242..c9be4ee 100644 --- a/lib/services/database.dart +++ b/lib/services/database.dart @@ -11,16 +11,12 @@ class DatabaseService { DatabaseService({this.uid}); //collection reference - final CollectionReference> userDetails = - FirebaseFirestore.instance.collection('userdetails'); - final CollectionReference> groupdetails = - FirebaseFirestore.instance.collection('group'); - final CollectionReference> requests = - FirebaseFirestore.instance.collection('requests'); + final CollectionReference> userDetails = FirebaseFirestore.instance.collection('userdetails'); + final CollectionReference> groupdetails = FirebaseFirestore.instance.collection('group'); + final CollectionReference> requests = FirebaseFirestore.instance.collection('requests'); // Enter user data (W=1, R=0) - Future enterUserData( - {String name, String mobileNumber, String hostel, String sex}) async { + Future enterUserData({String name, String mobileNumber, String hostel, String sex}) async { return await userDetails.doc(uid).set({ 'name': name, 'mobileNumber': mobileNumber, @@ -34,15 +30,10 @@ class DatabaseService { } // Update user data (W=1/2,R=1) - Future updateUserData( - {String name, String mobileNumber, String hostel, String sex}) async { + Future updateUserData({String name, String mobileNumber, String hostel, String sex}) async { var currentGrp; var user = _auth.currentUser; - await FirebaseFirestore.instance - .collection('userdetails') - .doc(user.uid) - .get() - .then((value) { + await FirebaseFirestore.instance.collection('userdetails').doc(user.uid).get().then((value) { currentGrp = value.data()['currentGroup']; }); await userDetails.doc(uid).update({ @@ -62,8 +53,7 @@ class DatabaseService { } // user list from snapshot - List _UserListFromSnapshot( - QuerySnapshot> snapshot) { + List _UserListFromSnapshot(QuerySnapshot> snapshot) { return snapshot.docs.map((doc) { return Userdetails( uid: doc.id, @@ -96,19 +86,9 @@ class DatabaseService { // CODE FOR CONVERTING DATE TIME TO TIMESTAMP var temp = requestDetails.startTime; - var starting = DateTime( - requestDetails.startDate.year, - requestDetails.startDate.month, - requestDetails.startDate.day, - temp.hour, - temp.minute); + var starting = DateTime(requestDetails.startDate.year, requestDetails.startDate.month, requestDetails.startDate.day, temp.hour, temp.minute); var temp2 = requestDetails.endTime; - var ending = DateTime( - requestDetails.endDate.year, - requestDetails.endDate.month, - requestDetails.endDate.day, - temp2.hour, - temp2.minute); + var ending = DateTime(requestDetails.endDate.year, requestDetails.endDate.month, requestDetails.endDate.day, temp2.hour, temp2.minute); final docRef = await groupdetails.add({ 'owner': user.uid.toString(), @@ -124,37 +104,22 @@ class DatabaseService { }); //adding user to group chat - await ChatService().createChatRoom( - docRef.id, user.uid.toString(), requestDetails.destination.toString()); + await ChatService().createChatRoom(docRef.id, user.uid.toString(), requestDetails.destination.toString()); await userDetails.doc(user.uid).update({ 'currentGroup': docRef.id, }); var request = groupdetails.doc(docRef.id).collection('users'); - await FirebaseFirestore.instance - .collection('userdetails') - .doc(user.uid) - .get() - .then((value) async { + await FirebaseFirestore.instance.collection('userdetails').doc(user.uid).get().then((value) async { if (value.exists) { - await request.doc(user.uid).set({ - 'name': value.data()['name'], - 'hostel': value.data()['hostel'], - 'sex': value.data()['sex'], - 'mobilenum': value.data()['mobileNumber'], - 'totalrides': value.data()['totalRides'], - 'cancelledrides': value.data()['cancelledRides'], - 'actualrating': value.data()['actualRating'], - 'numberofratings': value.data()['numberOfRatings'] - }); + await request.doc(user.uid).set({'name': value.data()['name'], 'hostel': value.data()['hostel'], 'sex': value.data()['sex'], 'mobilenum': value.data()['mobileNumber'], 'totalrides': value.data()['totalRides'], 'cancelledrides': value.data()['cancelledRides'], 'actualrating': value.data()['actualRating'], 'numberofratings': value.data()['numberOfRatings']}); } }); } // to update group details (W=1, R=0) - Future updateGroup(String groupUID, DateTime SD, TimeOfDay ST, - DateTime ED, TimeOfDay ET, bool privacy, int maxPoolers) async { + Future updateGroup(String groupUID, DateTime SD, TimeOfDay ST, DateTime ED, TimeOfDay ET, bool privacy, int maxPoolers) async { var starting = DateTime(SD.year, SD.month, SD.day, ST.hour, ST.minute); var ending = DateTime(ED.year, ED.month, ED.day, ET.hour, ET.minute); @@ -175,11 +140,7 @@ class DatabaseService { var totalRides; var cancelledRides; var owner; - await FirebaseFirestore.instance - .collection('userdetails') - .doc(user.uid) - .get() - .then((value) { + await FirebaseFirestore.instance.collection('userdetails').doc(user.uid).get().then((value) { currentGrp = value.data()['currentGroup']; totalRides = value.data()['totalRides']; cancelledRides = value.data()['cancelledRides']; @@ -208,11 +169,7 @@ class DatabaseService { 'owner': newowner, }); } - await groupdetails - .doc(currentGrp) - .collection('users') - .doc(user.uid) - .delete(); + await groupdetails.doc(currentGrp).collection('users').doc(user.uid).delete(); //deleting user from chat group await ChatService().exitChatRoom(currentGrp); } @@ -247,11 +204,7 @@ class DatabaseService { }); var request = groupdetails.doc(listuid).collection('users'); - await FirebaseFirestore.instance - .collection('userdetails') - .doc(user.uid) - .get() - .then((value) async { + await FirebaseFirestore.instance.collection('userdetails').doc(user.uid).get().then((value) async { if (value.exists) { await request.doc(user.uid).set({ 'name': value.data()['name'], From e75984afdb66c999055d89be0e1ce0a4601b3c22 Mon Sep 17 00:00:00 2001 From: as1605 <1605.aditya.singh@gmail.com> Date: Sun, 19 Dec 2021 17:54:48 +0530 Subject: [PATCH 7/9] IPHONEOS_DEPLOYMENT_TARGET = 12.0 --- ios/Runner.xcodeproj/project.pbxproj | 27 +++++++------------ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ 2 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 26d3262..9a9c64f 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -78,7 +78,6 @@ F523DB7D5FBDE13AA19376B1 /* Pods-Runner.release.xcconfig */, 2596A5A1C733469C49985A17 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -387,7 +386,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -409,10 +408,8 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -472,7 +469,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -521,7 +518,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -544,10 +541,8 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -574,10 +569,8 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + From f4ace9b7d86016467cd35b6df50559e8b3282b0c Mon Sep 17 00:00:00 2001 From: as1605 <1605.aditya.singh@gmail.com> Date: Sun, 23 Jan 2022 17:54:04 +0530 Subject: [PATCH 8/9] Configured firebaseflutter. Use proper way to check if key exists. Set all fields in registration @jasrajsb --- lib/firebase_options.dart | 54 ++++++++++++++++++++++++ lib/main.dart | 89 ++++++++++++++++++++++++++++++--------- 2 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 lib/firebase_options.dart diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart new file mode 100644 index 0000000..6a10a6d --- /dev/null +++ b/lib/firebase_options.dart @@ -0,0 +1,54 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: lines_longer_than_80_chars +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + // ignore: missing_enum_constant_in_switch + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for ios - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyCK0fGYjIa79OGe7oDe1yXXu_tDykaArzo', + appId: '1:601602499777:android:ed43aee964570d9ea9a040', + messagingSenderId: '601602499777', + projectId: 'shareacab-df9e9', + databaseURL: 'https://shareacab-df9e9.firebaseio.com', + storageBucket: 'shareacab-df9e9.appspot.com', + ); +} diff --git a/lib/main.dart b/lib/main.dart index 60be0ab..0df574e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,10 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:shareacab/screens/chatscreen/chat_screen.dart'; +// Import the generated file +import 'package:firebase_core/firebase_core.dart'; +import 'firebase_options.dart'; + Color userIsOnline(BuildContext context) => Colors.green; Color sendMessageIcon(BuildContext context) => Colors.green; @@ -50,8 +54,10 @@ ThemeData getSearchAppBarTheme(BuildContext context) { } } -Color chatBubbleBackgroundColorReceiver = Colors.lightBlue; // Needs to be changed acc to combinations, requires creativity -Color chatBubbleBackgroundColorSender = Colors.lightGreen; // Needs to be changed acc to combinations, requires creativity +Color chatBubbleBackgroundColorReceiver = Colors + .lightBlue; // Needs to be changed acc to combinations, requires creativity +Color chatBubbleBackgroundColorSender = Colors + .lightGreen; // Needs to be changed acc to combinations, requires creativity Color chatSearchBackgroundColor = Colors.white; Color getVisibleColorOnPrimaryColor(BuildContext context) { @@ -60,7 +66,12 @@ Color getVisibleColorOnPrimaryColor(BuildContext context) { Color getVisibleColorOnAccentColor(BuildContext context) { var color = Theme.of(context).colorScheme.secondary; - var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; + var list = [ + Colors.tealAccent, + Colors.cyanAccent, + Colors.yellowAccent, + Colors.greenAccent + ]; if (list.contains(color)) { return Colors.black; } @@ -75,7 +86,12 @@ Color getVisibleTextColorOnScaffold(BuildContext context) { } else { theme = 'light'; } - var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; + var list = [ + Colors.tealAccent, + Colors.cyanAccent, + Colors.yellowAccent, + Colors.greenAccent + ]; if (list.contains(color) && theme == 'light') { return Colors.black; } else { @@ -91,7 +107,12 @@ Color getVisibleIconColorOnScaffold(BuildContext context) { } else { theme = 'light'; } - var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; + var list = [ + Colors.tealAccent, + Colors.cyanAccent, + Colors.yellowAccent, + Colors.greenAccent + ]; if (list.contains(color) && theme == 'light') { if (color == Colors.cyanAccent) { return Colors.cyan; @@ -137,15 +158,19 @@ class ThemeNotifier with ChangeNotifier { } } -void main() { +Future main() async { WidgetsFlutterBinding.ensureInitialized(); - SharedPreferences.getInstance().then((prefs) { - if (prefs.getBool('darkMode') == null || prefs.getString('accentColor') == null) { + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + await SharedPreferences.getInstance().then((prefs) { + if (prefs.getBool('darkMode') == null || + prefs.getString('accentColor') == null) { prefs.setBool('darkMode', true); prefs.setString('accentColor', 'Blue'); } }); - SharedPreferences.getInstance().then((prefs) { + await SharedPreferences.getInstance().then((prefs) { var darkModeOn = prefs.getBool('darkMode') ?? true; var _theme = prefs.getString('theme') ?? 'system'; var chosenAccentColor = prefs.getString('accentColor') ?? 'Blue'; @@ -164,63 +189,80 @@ void main() { if (chosenAccentColor == 'Blue') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Cyan') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Teal') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Purple') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Red') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.redAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.redAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Orange') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Yellow') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Green') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), + darkModeOn), child: MyApp(), ), ); } else { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier( + getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), child: MyApp(), ), ); @@ -272,8 +314,12 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { backgroundColor: const Color(0xFF212121), dividerColor: Colors.black12, scaffoldBackgroundColor: Colors.black, - textSelectionTheme: TextSelectionThemeData(cursorColor: Colors.white, selectionColor: Colors.blue, selectionHandleColor: Colors.blue), - colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(secondary: accentColor), + textSelectionTheme: TextSelectionThemeData( + cursorColor: Colors.white, + selectionColor: Colors.blue, + selectionHandleColor: Colors.blue), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) + .copyWith(secondary: accentColor), ) : ThemeData( appBarTheme: AppBarTheme(color: Colors.black), @@ -289,6 +335,7 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { selectionColor: Colors.blueGrey[700], selectionHandleColor: Colors.blueGrey[700], ), - colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(secondary: accentColor), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) + .copyWith(secondary: accentColor), ); } From 665c7216bc688ff0e68fdc99f3413659a9173b6d Mon Sep 17 00:00:00 2001 From: as1605 <1605.aditya.singh@gmail.com> Date: Sun, 23 Jan 2022 17:56:08 +0530 Subject: [PATCH 9/9] dart format . -l 900 --- lib/firebase_options.dart | 3 +- lib/main.dart | 76 ++++++++++----------------------------- 2 files changed, 19 insertions(+), 60 deletions(-) diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart index 6a10a6d..efda77e 100644 --- a/lib/firebase_options.dart +++ b/lib/firebase_options.dart @@ -1,8 +1,7 @@ // File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; -import 'package:flutter/foundation.dart' - show defaultTargetPlatform, kIsWeb, TargetPlatform; +import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// diff --git a/lib/main.dart b/lib/main.dart index 0df574e..d45ca3c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,10 +54,8 @@ ThemeData getSearchAppBarTheme(BuildContext context) { } } -Color chatBubbleBackgroundColorReceiver = Colors - .lightBlue; // Needs to be changed acc to combinations, requires creativity -Color chatBubbleBackgroundColorSender = Colors - .lightGreen; // Needs to be changed acc to combinations, requires creativity +Color chatBubbleBackgroundColorReceiver = Colors.lightBlue; // Needs to be changed acc to combinations, requires creativity +Color chatBubbleBackgroundColorSender = Colors.lightGreen; // Needs to be changed acc to combinations, requires creativity Color chatSearchBackgroundColor = Colors.white; Color getVisibleColorOnPrimaryColor(BuildContext context) { @@ -66,12 +64,7 @@ Color getVisibleColorOnPrimaryColor(BuildContext context) { Color getVisibleColorOnAccentColor(BuildContext context) { var color = Theme.of(context).colorScheme.secondary; - var list = [ - Colors.tealAccent, - Colors.cyanAccent, - Colors.yellowAccent, - Colors.greenAccent - ]; + var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; if (list.contains(color)) { return Colors.black; } @@ -86,12 +79,7 @@ Color getVisibleTextColorOnScaffold(BuildContext context) { } else { theme = 'light'; } - var list = [ - Colors.tealAccent, - Colors.cyanAccent, - Colors.yellowAccent, - Colors.greenAccent - ]; + var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; if (list.contains(color) && theme == 'light') { return Colors.black; } else { @@ -107,12 +95,7 @@ Color getVisibleIconColorOnScaffold(BuildContext context) { } else { theme = 'light'; } - var list = [ - Colors.tealAccent, - Colors.cyanAccent, - Colors.yellowAccent, - Colors.greenAccent - ]; + var list = [Colors.tealAccent, Colors.cyanAccent, Colors.yellowAccent, Colors.greenAccent]; if (list.contains(color) && theme == 'light') { if (color == Colors.cyanAccent) { return Colors.cyan; @@ -164,8 +147,7 @@ Future main() async { options: DefaultFirebaseOptions.currentPlatform, ); await SharedPreferences.getInstance().then((prefs) { - if (prefs.getBool('darkMode') == null || - prefs.getString('accentColor') == null) { + if (prefs.getBool('darkMode') == null || prefs.getString('accentColor') == null) { prefs.setBool('darkMode', true); prefs.setString('accentColor', 'Blue'); } @@ -189,80 +171,63 @@ Future main() async { if (chosenAccentColor == 'Blue') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blueAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Cyan') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.cyanAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Teal') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.tealAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Purple') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.purpleAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Red') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.redAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.redAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Orange') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.deepOrangeAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Yellow') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.yellowAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else if (chosenAccentColor == 'Green') { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), - darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.greenAccent, darkModeOn), darkModeOn), child: MyApp(), ), ); } else { runApp( ChangeNotifierProvider( - create: (_) => ThemeNotifier( - getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), + create: (_) => ThemeNotifier(getThemeDataForAccentColor(Colors.blue, darkModeOn), darkModeOn), child: MyApp(), ), ); @@ -314,12 +279,8 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { backgroundColor: const Color(0xFF212121), dividerColor: Colors.black12, scaffoldBackgroundColor: Colors.black, - textSelectionTheme: TextSelectionThemeData( - cursorColor: Colors.white, - selectionColor: Colors.blue, - selectionHandleColor: Colors.blue), - colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) - .copyWith(secondary: accentColor), + textSelectionTheme: TextSelectionThemeData(cursorColor: Colors.white, selectionColor: Colors.blue, selectionHandleColor: Colors.blue), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(secondary: accentColor), ) : ThemeData( appBarTheme: AppBarTheme(color: Colors.black), @@ -335,7 +296,6 @@ ThemeData getThemeDataForAccentColor(Color accentColor, bool darkTheme) { selectionColor: Colors.blueGrey[700], selectionHandleColor: Colors.blueGrey[700], ), - colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey) - .copyWith(secondary: accentColor), + colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(secondary: accentColor), ); }