From 76892d1ece69a25c56e04678db451e1e988dc8ac Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 11:40:47 +0530 Subject: [PATCH 1/8] Implement core function for google sign-n --- .idea/libraries/Dart_Packages.xml | 788 ++++++++++++++++++ .idea/libraries/Flutter_Plugins.xml | 7 +- app/ios/Podfile.lock | 7 - app/lib/main.dart | 4 +- app/lib/ui/flow/main/main_screen.dart | 24 +- .../ui/flow/main/main_screen_view_model.dart | 40 + .../main/main_screen_view_model.freezed.dart | 129 +++ .../ui/flow/settings /settings_screen.dart | 19 - app/lib/ui/navigation/app_router.dart | 11 - app/pubspec.lock | 24 +- app/pubspec.yaml | 7 +- build_watch | 23 + data/.flutter-plugins-dependencies | 2 +- data/lib/services/auth_service.dart | 42 + data/lib/services/google_drive_service.dart | 25 + data/pubspec.yaml | 12 +- 16 files changed, 1116 insertions(+), 48 deletions(-) create mode 100644 .idea/libraries/Dart_Packages.xml create mode 100644 app/lib/ui/flow/main/main_screen_view_model.dart create mode 100644 app/lib/ui/flow/main/main_screen_view_model.freezed.dart delete mode 100644 app/lib/ui/flow/settings /settings_screen.dart create mode 100755 build_watch create mode 100644 data/lib/services/auth_service.dart create mode 100644 data/lib/services/google_drive_service.dart diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml new file mode 100644 index 0000000..44578dc --- /dev/null +++ b/.idea/libraries/Dart_Packages.xml @@ -0,0 +1,788 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index b0f6971..c4e0028 100644 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -1,6 +1,11 @@ - + + + + + + diff --git a/app/ios/Podfile.lock b/app/ios/Podfile.lock index ba916c3..d20d5f1 100644 --- a/app/ios/Podfile.lock +++ b/app/ios/Podfile.lock @@ -18,14 +18,10 @@ PODS: - AppAuth/Core (~> 1.6) - GTMSessionFetcher/Core (< 4.0, >= 1.5) - GTMSessionFetcher/Core (3.2.0) - - shared_preferences_foundation (0.0.1): - - Flutter - - FlutterMacOS DEPENDENCIES: - Flutter (from `Flutter`) - google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) - - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) SPEC REPOS: trunk: @@ -39,8 +35,6 @@ EXTERNAL SOURCES: :path: Flutter google_sign_in_ios: :path: ".symlinks/plugins/google_sign_in_ios/darwin" - shared_preferences_foundation: - :path: ".symlinks/plugins/shared_preferences_foundation/darwin" SPEC CHECKSUMS: AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570 @@ -49,7 +43,6 @@ SPEC CHECKSUMS: GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842 GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae GTMSessionFetcher: 41b9ef0b4c08a6db4b7eb51a21ae5183ec99a2c8 - shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 diff --git a/app/lib/main.dart b/app/lib/main.dart index ebc08bf..b6163bc 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -1,8 +1,10 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'ui/app.dart'; void main() { - runApp(const CloudGalleryApp()); + final container = ProviderContainer(); + runApp(UncontrolledProviderScope(container: container, child: const CloudGalleryApp()) ); } class CloudGalleryApp extends StatefulWidget { diff --git a/app/lib/ui/flow/main/main_screen.dart b/app/lib/ui/flow/main/main_screen.dart index de5e872..3469ea8 100644 --- a/app/lib/ui/flow/main/main_screen.dart +++ b/app/lib/ui/flow/main/main_screen.dart @@ -1,4 +1,6 @@ +import 'package:cloud_gallery/ui/flow/main/main_screen_view_model.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @@ -12,7 +14,25 @@ class _MainScreenState extends State { Widget build(BuildContext context) { return const Scaffold( body: Center( - child: Text("Home Screen"), - )); + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [Button()], + ), + )); + } +} + +class Button extends ConsumerWidget { + const Button({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final notifier = ref.read(mainScreenViewNotifierProvider.notifier); + return TextButton( + onPressed: () { + notifier.getFiles(); + }, + child: const Text("Get DriveFiles")); } } diff --git a/app/lib/ui/flow/main/main_screen_view_model.dart b/app/lib/ui/flow/main/main_screen_view_model.dart new file mode 100644 index 0000000..883cd52 --- /dev/null +++ b/app/lib/ui/flow/main/main_screen_view_model.dart @@ -0,0 +1,40 @@ +import 'package:data/services/auth_service.dart'; +import 'package:data/services/google_drive_service.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'main_screen_view_model.freezed.dart'; + +final mainScreenViewNotifierProvider = StateNotifierProvider.autoDispose< + MainScreenViewNotifier, MainScreenViewState>( + (ref) => MainScreenViewNotifier( + ref.watch(authServiceProvider), + ref.read(googleDriveServiceProvider) + ), +); + +class MainScreenViewNotifier extends StateNotifier { + MainScreenViewNotifier( + this._authService, + this._googleDriveService, + ) : super(const MainScreenViewState()); + + final AuthService _authService; + final GoogleDriveService _googleDriveService; + + Future getFiles() async { + try { + await _authService.signInWithGoogle(); + await _googleDriveService.getDriveFiles(); + } catch (error) { + state = state.copyWith(error: error); + } + } +} + +@freezed +class MainScreenViewState with _$MainScreenViewState { + const factory MainScreenViewState({ + Object? error, + }) = _MainScreenViewState; +} diff --git a/app/lib/ui/flow/main/main_screen_view_model.freezed.dart b/app/lib/ui/flow/main/main_screen_view_model.freezed.dart new file mode 100644 index 0000000..9be4419 --- /dev/null +++ b/app/lib/ui/flow/main/main_screen_view_model.freezed.dart @@ -0,0 +1,129 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'main_screen_view_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$MainScreenViewState { + Object? get error => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $MainScreenViewStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MainScreenViewStateCopyWith<$Res> { + factory $MainScreenViewStateCopyWith( + MainScreenViewState value, $Res Function(MainScreenViewState) then) = + _$MainScreenViewStateCopyWithImpl<$Res, MainScreenViewState>; + @useResult + $Res call({Object? error}); +} + +/// @nodoc +class _$MainScreenViewStateCopyWithImpl<$Res, $Val extends MainScreenViewState> + implements $MainScreenViewStateCopyWith<$Res> { + _$MainScreenViewStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? error = freezed, + }) { + return _then(_value.copyWith( + error: freezed == error ? _value.error : error, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MainScreenViewStateImplCopyWith<$Res> + implements $MainScreenViewStateCopyWith<$Res> { + factory _$$MainScreenViewStateImplCopyWith(_$MainScreenViewStateImpl value, + $Res Function(_$MainScreenViewStateImpl) then) = + __$$MainScreenViewStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({Object? error}); +} + +/// @nodoc +class __$$MainScreenViewStateImplCopyWithImpl<$Res> + extends _$MainScreenViewStateCopyWithImpl<$Res, _$MainScreenViewStateImpl> + implements _$$MainScreenViewStateImplCopyWith<$Res> { + __$$MainScreenViewStateImplCopyWithImpl(_$MainScreenViewStateImpl _value, + $Res Function(_$MainScreenViewStateImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? error = freezed, + }) { + return _then(_$MainScreenViewStateImpl( + error: freezed == error ? _value.error : error, + )); + } +} + +/// @nodoc + +class _$MainScreenViewStateImpl implements _MainScreenViewState { + const _$MainScreenViewStateImpl({this.error}); + + @override + final Object? error; + + @override + String toString() { + return 'MainScreenViewState(error: $error)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MainScreenViewStateImpl && + const DeepCollectionEquality().equals(other.error, error)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(error)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MainScreenViewStateImplCopyWith<_$MainScreenViewStateImpl> get copyWith => + __$$MainScreenViewStateImplCopyWithImpl<_$MainScreenViewStateImpl>( + this, _$identity); +} + +abstract class _MainScreenViewState implements MainScreenViewState { + const factory _MainScreenViewState({final Object? error}) = + _$MainScreenViewStateImpl; + + @override + Object? get error; + @override + @JsonKey(ignore: true) + _$$MainScreenViewStateImplCopyWith<_$MainScreenViewStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/app/lib/ui/flow/settings /settings_screen.dart b/app/lib/ui/flow/settings /settings_screen.dart deleted file mode 100644 index b611ddb..0000000 --- a/app/lib/ui/flow/settings /settings_screen.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:flutter/material.dart'; - -class SettingsScreen extends StatefulWidget { - const SettingsScreen({super.key}); - - @override - State createState() => _SettingsScreenState(); -} - -class _SettingsScreenState extends State { - @override - Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: Text("Settings Screen"), - ), - ); - } -} diff --git a/app/lib/ui/navigation/app_router.dart b/app/lib/ui/navigation/app_router.dart index 77be5c0..2821b13 100644 --- a/app/lib/ui/navigation/app_router.dart +++ b/app/lib/ui/navigation/app_router.dart @@ -1,5 +1,4 @@ import 'package:cloud_gallery/ui/flow/main/main_screen.dart'; -import 'package:cloud_gallery/ui/flow/settings%20/settings_screen.dart'; import 'package:go_router/go_router.dart'; import 'app_route.dart'; @@ -9,21 +8,11 @@ class AppRouter { builder: (context) => const HomeScreen(), ); - static AppRoute get settings => AppRoute( - AppRoutePath.settings, - builder: (context) => const SettingsScreen(), - ); - static final routes = [ home.goRoute, - GoRoute( - path: AppRoutePath.settings, - builder: (context, state) => state.widget(context), - ), ]; } class AppRoutePath { static const home = '/'; - static const settings = '/settings'; } diff --git a/app/pubspec.lock b/app/pubspec.lock index 8b6bddf..0654a9a 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -240,6 +240,14 @@ packages: relative: true source: path version: "0.0.1" + extension_google_sign_in_as_googleapis_auth: + dependency: transitive + description: + name: extension_google_sign_in_as_googleapis_auth + sha256: bcf4f8dedcc1e66ce5fe98fbd98cc86ed25ad7fce0511e8d6cdc46ccbf421e8e + url: "https://pub.dev" + source: hosted + version: "2.0.12" fake_async: dependency: transitive description: @@ -301,7 +309,7 @@ packages: source: sdk version: "0.0.0" freezed: - dependency: "direct dev" + dependency: "direct main" description: name: freezed sha256: "6c5031daae12c7072b3a87eff98983076434b4889ef2a44384d0cae3f82372ba" @@ -309,7 +317,7 @@ packages: source: hosted version: "2.4.6" freezed_annotation: - dependency: transitive + dependency: "direct main" description: name: freezed_annotation sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d @@ -396,6 +404,14 @@ packages: url: "https://pub.dev" source: hosted version: "12.0.0" + googleapis_auth: + dependency: transitive + description: + name: googleapis_auth + sha256: "127b1bbd32170ab8312f503bd57f1d654d8e4039ddfbc63c027d3f7ade0eff74" + url: "https://pub.dev" + source: hosted + version: "1.3.1" graphs: dependency: transitive description: @@ -416,10 +432,10 @@ packages: dependency: transitive description: name: http - sha256: d4872660c46d929f6b8a9ef4e7a7eff7e49bbf0c4ec3f385ee32df5119175139 + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "0.13.6" http_multi_server: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 10bfea1..4c87b88 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -32,6 +32,10 @@ dependencies: # navigation go_router: ^13.0.1 + # ode generation + freezed: ^2.4.6 + freezed_annotation: ^2.4.1 + dev_dependencies: flutter_test: @@ -43,7 +47,8 @@ dev_dependencies: # code generation build_runner: ^2.3.3 - freezed: ^2.4.6 + + flutter: diff --git a/build_watch b/build_watch new file mode 100755 index 0000000..cf7c5a9 --- /dev/null +++ b/build_watch @@ -0,0 +1,23 @@ +#!/bin/bash + +# Function to terminate all background processes on exit +function cleanup { + pkill -P $$ +} +trap cleanup EXIT + +# Function to keep running a command until it succeeds +function keep_running { + while true; do + dart run build_runner watch --delete-conflicting-outputs; + echo "Command failed with no zero exit code. Respawning.." + sleep 1 + done +} + +# Navigate to each project directory and run the watcher in the background +(cd app && keep_running) & +(cd data && keep_running) & + +# Wait for all background processes to finish +wait diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index ece4333..7f77bf3 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-16 16:13:35.297035","version":"3.16.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-17 11:19:03.657909","version":"3.16.5"} \ No newline at end of file diff --git a/data/lib/services/auth_service.dart b/data/lib/services/auth_service.dart new file mode 100644 index 0000000..3dc66ef --- /dev/null +++ b/data/lib/services/auth_service.dart @@ -0,0 +1,42 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:googleapis/drive/v3.dart' as drive; + +final googleSignInProvider = Provider( + (ref) => GoogleSignIn( + scopes: [ + drive.DriveApi.driveFileScope, + ], + ), +); + +final authServiceProvider = Provider( + (ref) => AuthService(ref.read(googleSignInProvider)), +); + +class AuthService { + final GoogleSignIn _googleSignIn; + + const AuthService( + this._googleSignIn, + ); + + Future signInWithGoogle() async { + try { + final googleSignInAccount = await _googleSignIn.signIn(); + if (googleSignInAccount != null) { + await googleSignInAccount.authentication; + } + } catch (_) { + rethrow; + } + } + + Future signOutWithGoogle() async { + try { + await _googleSignIn.signOut(); + } catch (_) { + rethrow; + } + } +} diff --git a/data/lib/services/google_drive_service.dart b/data/lib/services/google_drive_service.dart new file mode 100644 index 0000000..4f6106e --- /dev/null +++ b/data/lib/services/google_drive_service.dart @@ -0,0 +1,25 @@ +import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:googleapis/drive/v3.dart' as drive; +import 'auth_service.dart'; + +final googleDriveServiceProvider = Provider( + (ref) => GoogleDriveService(ref.read(googleSignInProvider)), +); + +class GoogleDriveService { + final GoogleSignIn _googleSignIn; + + const GoogleDriveService(this._googleSignIn); + + Future getDriveFiles() async { + if (_googleSignIn.currentUser != null) { + final client = await _googleSignIn.authenticatedClient(); + if (client == null) return; + final driveApi = drive.DriveApi(client); + final files = await driveApi.files.list(); + print(files); + } + } +} diff --git a/data/pubspec.yaml b/data/pubspec.yaml index bc02f81..da6ae01 100644 --- a/data/pubspec.yaml +++ b/data/pubspec.yaml @@ -12,7 +12,17 @@ dependencies: # services googleapis: ^12.0.0 + + # authentication google_sign_in: ^6.2.1 + extension_google_sign_in_as_googleapis_auth: ^2.0.12 + + # state management + flutter_riverpod: ^2.4.9 + + # ode generation + freezed: ^2.4.6 + freezed_annotation: ^2.4.1 dev_dependencies: flutter_test: @@ -24,7 +34,7 @@ dev_dependencies: # code generation build_runner: ^2.3.3 - freezed: ^2.4.6 + flutter: From afce10d33eace5f9cdf4c5c27a15ff28a749a87f Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 12:16:06 +0530 Subject: [PATCH 2/8] Fix Directory issue --- .idea/libraries/Dart_Packages.xml | 26 ++++++++++++++++++++++++-- .idea/vcs.xml | 6 ++++++ data/.flutter-plugins-dependencies | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index 44578dc..ad81025 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -205,6 +205,13 @@ + + + + + + @@ -352,6 +359,14 @@ + + + + + + @@ -369,7 +384,8 @@ - @@ -405,6 +421,7 @@ @@ -713,6 +730,7 @@ + @@ -730,13 +748,17 @@ + + - + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index 7f77bf3..c798f81 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-17 11:19:03.657909","version":"3.16.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-17 12:15:03.226319","version":"3.16.5"} \ No newline at end of file From 28b820f04840481afb98f64a5901353a7eb4e9d3 Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 12:33:35 +0530 Subject: [PATCH 3/8] Initialize firebase --- app/android/app/google-services.json | 29 +++++++++++++++++ app/ios/Podfile.lock | 31 +++++++++++++++++++ app/ios/Runner.xcodeproj/project.pbxproj | 4 +++ app/ios/Runner/GoogleService-Info.plist | 30 ++++++++++++++++++ app/ios/firebase_app_id_file.json | 7 +++++ app/lib/main.dart | 9 ++++-- .../Flutter/GeneratedPluginRegistrant.swift | 2 ++ app/pubspec.lock | 28 +++++++++++++++-- app/pubspec.yaml | 5 ++- .../flutter/generated_plugin_registrant.cc | 3 ++ app/windows/flutter/generated_plugins.cmake | 1 + data/.flutter-plugins-dependencies | 2 +- data/lib/services/google_drive_service.dart | 5 ++- 13 files changed, 148 insertions(+), 8 deletions(-) create mode 100644 app/android/app/google-services.json create mode 100644 app/ios/Runner/GoogleService-Info.plist create mode 100644 app/ios/firebase_app_id_file.json diff --git a/app/android/app/google-services.json b/app/android/app/google-services.json new file mode 100644 index 0000000..19cd78b --- /dev/null +++ b/app/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "64221198282", + "project_id": "cloud-gallery-auth", + "storage_bucket": "cloud-gallery-auth.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:64221198282:android:64782148b88407396e8133", + "android_client_info": { + "package_name": "com.canopas.cloud_gallery" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyABDkRcwTA2gwgjBtx5GGNLgAsCHKY7Rpc" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/ios/Podfile.lock b/app/ios/Podfile.lock index d20d5f1..a9a28a7 100644 --- a/app/ios/Podfile.lock +++ b/app/ios/Podfile.lock @@ -5,6 +5,17 @@ PODS: - AppAuth/Core (1.6.2) - AppAuth/ExternalUserAgent (1.6.2): - AppAuth/Core + - Firebase/CoreOnly (10.18.0): + - FirebaseCore (= 10.18.0) + - firebase_core (2.24.2): + - Firebase/CoreOnly (= 10.18.0) + - Flutter + - FirebaseCore (10.18.0): + - FirebaseCoreInternal (~> 10.0) + - GoogleUtilities/Environment (~> 7.12) + - GoogleUtilities/Logger (~> 7.12) + - FirebaseCoreInternal (10.19.0): + - "GoogleUtilities/NSData+zlib (~> 7.8)" - Flutter (1.0.0) - google_sign_in_ios (0.0.1): - Flutter @@ -14,23 +25,37 @@ PODS: - AppAuth (~> 1.5) - GTMAppAuth (< 3.0, >= 1.3) - GTMSessionFetcher/Core (< 4.0, >= 1.1) + - GoogleUtilities/Environment (7.12.0): + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Logger (7.12.0): + - GoogleUtilities/Environment + - "GoogleUtilities/NSData+zlib (7.12.0)" - GTMAppAuth (2.0.0): - AppAuth/Core (~> 1.6) - GTMSessionFetcher/Core (< 4.0, >= 1.5) - GTMSessionFetcher/Core (3.2.0) + - PromisesObjC (2.3.1) DEPENDENCIES: + - firebase_core (from `.symlinks/plugins/firebase_core/ios`) - Flutter (from `Flutter`) - google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) SPEC REPOS: trunk: - AppAuth + - Firebase + - FirebaseCore + - FirebaseCoreInternal - GoogleSignIn + - GoogleUtilities - GTMAppAuth - GTMSessionFetcher + - PromisesObjC EXTERNAL SOURCES: + firebase_core: + :path: ".symlinks/plugins/firebase_core/ios" Flutter: :path: Flutter google_sign_in_ios: @@ -38,11 +63,17 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570 + Firebase: 414ad272f8d02dfbf12662a9d43f4bba9bec2a06 + firebase_core: 0af4a2b24f62071f9bf283691c0ee41556dcb3f5 + FirebaseCore: 2322423314d92f946219c8791674d2f3345b598f + FirebaseCoreInternal: b444828ea7cfd594fca83046b95db98a2be4f290 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 google_sign_in_ios: 1bfaf6607b44cd1b24c4d4bc39719870440f9ce1 GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842 + GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34 GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae GTMSessionFetcher: 41b9ef0b4c08a6db4b7eb51a21ae5183ec99a2c8 + PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 diff --git a/app/ios/Runner.xcodeproj/project.pbxproj b/app/ios/Runner.xcodeproj/project.pbxproj index 14ab8ba..d23556a 100644 --- a/app/ios/Runner.xcodeproj/project.pbxproj +++ b/app/ios/Runner.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + ADB0F54A909CECF6AE7126A9 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1DCBF06C22B4C2B81ABC49EC /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -45,6 +46,7 @@ 0B0DC1FB5EAC2980BA93FC3A /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 1DCBF06C22B4C2B81ABC49EC /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; @@ -129,6 +131,7 @@ 331C8082294A63A400263BE5 /* RunnerTests */, 1812CDCCD7D8EE1D81BEB3EF /* Pods */, E90E204BBB1CD9A3DD7B3F25 /* Frameworks */, + 1DCBF06C22B4C2B81ABC49EC /* GoogleService-Info.plist */, ); sourceTree = ""; }; @@ -265,6 +268,7 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ADB0F54A909CECF6AE7126A9 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/app/ios/Runner/GoogleService-Info.plist b/app/ios/Runner/GoogleService-Info.plist new file mode 100644 index 0000000..da91891 --- /dev/null +++ b/app/ios/Runner/GoogleService-Info.plist @@ -0,0 +1,30 @@ + + + + + API_KEY + AIzaSyDOoeWHX2RlxHcQ_QUHvR-tZJk_RsFluwY + GCM_SENDER_ID + 64221198282 + PLIST_VERSION + 1 + BUNDLE_ID + com.canopas.cloudGallery + PROJECT_ID + cloud-gallery-auth + STORAGE_BUCKET + cloud-gallery-auth.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:64221198282:ios:fcb315ff1f4bb4a66e8133 + + \ No newline at end of file diff --git a/app/ios/firebase_app_id_file.json b/app/ios/firebase_app_id_file.json new file mode 100644 index 0000000..cf0114a --- /dev/null +++ b/app/ios/firebase_app_id_file.json @@ -0,0 +1,7 @@ +{ + "file_generated_by": "FlutterFire CLI", + "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory", + "GOOGLE_APP_ID": "1:64221198282:ios:fcb315ff1f4bb4a66e8133", + "FIREBASE_PROJECT_ID": "cloud-gallery-auth", + "GCM_SENDER_ID": "64221198282" +} \ No newline at end of file diff --git a/app/lib/main.dart b/app/lib/main.dart index b6163bc..7c563a7 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -1,10 +1,14 @@ +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'ui/app.dart'; -void main() { +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(); final container = ProviderContainer(); - runApp(UncontrolledProviderScope(container: container, child: const CloudGalleryApp()) ); + runApp(UncontrolledProviderScope( + container: container, child: const CloudGalleryApp())); } class CloudGalleryApp extends StatefulWidget { @@ -20,4 +24,3 @@ class _CloudGalleryAppState extends State { return const App(); } } - diff --git a/app/macos/Flutter/GeneratedPluginRegistrant.swift b/app/macos/Flutter/GeneratedPluginRegistrant.swift index 82f2a45..8fd83c1 100644 --- a/app/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/app/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,10 @@ import FlutterMacOS import Foundation +import firebase_core import google_sign_in_ios func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin")) } diff --git a/app/pubspec.lock b/app/pubspec.lock index 0654a9a..1910b49 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -264,6 +264,30 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: "96607c0e829a581c2a483c658f04e8b159964c3bae2730f73297070bc85d40bb" + url: "https://pub.dev" + source: hosted + version: "2.24.2" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: c437ae5d17e6b5cc7981cf6fd458a5db4d12979905f9aafd1fea930428a9fe63 + url: "https://pub.dev" + source: hosted + version: "5.0.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: d585bdf3c656c3f7821ba1bd44da5f13365d22fcecaf5eb75c4295246aaa83c0 + url: "https://pub.dev" + source: hosted + version: "2.10.0" fixnum: dependency: transitive description: @@ -472,10 +496,10 @@ packages: dependency: transitive description: name: js - sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.7.0" + version: "0.6.7" json_annotation: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 4c87b88..547a6b1 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -32,7 +32,10 @@ dependencies: # navigation go_router: ^13.0.1 - # ode generation + # core + firebase_core: ^2.24.2 + + # code generation freezed: ^2.4.6 freezed_annotation: ^2.4.1 diff --git a/app/windows/flutter/generated_plugin_registrant.cc b/app/windows/flutter/generated_plugin_registrant.cc index 8b6d468..1a82e7d 100644 --- a/app/windows/flutter/generated_plugin_registrant.cc +++ b/app/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); } diff --git a/app/windows/flutter/generated_plugins.cmake b/app/windows/flutter/generated_plugins.cmake index b93c4c3..fa8a39b 100644 --- a/app/windows/flutter/generated_plugins.cmake +++ b/app/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + firebase_core ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index c798f81..4c66174 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-17 12:15:03.226319","version":"3.16.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-17 12:29:13.396414","version":"3.16.5"} \ No newline at end of file diff --git a/data/lib/services/google_drive_service.dart b/data/lib/services/google_drive_service.dart index 4f6106e..0db8117 100644 --- a/data/lib/services/google_drive_service.dart +++ b/data/lib/services/google_drive_service.dart @@ -1,4 +1,5 @@ import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:googleapis/drive/v3.dart' as drive; @@ -19,7 +20,9 @@ class GoogleDriveService { if (client == null) return; final driveApi = drive.DriveApi(client); final files = await driveApi.files.list(); - print(files); + if (kDebugMode) { + print(files); + } } } } From 7c0ce11ca8a4fee390fbe3a53bc7734edd487c90 Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 16:18:33 +0530 Subject: [PATCH 4/8] Set set up firebase --- app/android/app/build.gradle | 28 ++++++++++++++++++++---- app/android/app/google-services.json | 29 +++++++++++++++++++++++-- app/android/app/local.properties | 8 +++++++ app/android/build.gradle | 1 + app/ios/Runner/GoogleService-Info.plist | 4 ++++ app/ios/Runner/Info.plist | 13 +++++++++++ app/lib/main.dart | 2 ++ 7 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 app/android/app/local.properties diff --git a/app/android/app/build.gradle b/app/android/app/build.gradle index 14745d7..5c0a675 100644 --- a/app/android/app/build.gradle +++ b/app/android/app/build.gradle @@ -2,6 +2,7 @@ plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" + id "com.google.gms.google-services" } def localProperties = new Properties() @@ -51,11 +52,30 @@ android { versionName flutterVersionName } + signingConfigs { + if (System.getenv("APKSIGN_KEYSTORE") != null) { + release { + storeFile file(System.getenv("APKSIGN_KEYSTORE")) + storePassword System.getenv("APKSIGN_KEYSTORE_PASS") + keyAlias System.getenv("APKSIGN_KEY_ALIAS") + keyPassword System.getenv("APKSIGN_KEY_PASS") + } + } else { + release { + keyAlias 'cloud-gallery' + keyPassword 'canopas@cloud-gallery' + storeFile file('dev.jks') + storePassword 'canopas@cloud-gallery' + } + } + } + buildTypes { + debug { + signingConfig signingConfigs.release + } release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig signingConfigs.release } } } @@ -64,4 +84,4 @@ flutter { source '../..' } -dependencies {} +dependencies {} \ No newline at end of file diff --git a/app/android/app/google-services.json b/app/android/app/google-services.json index 19cd78b..6b6f018 100644 --- a/app/android/app/google-services.json +++ b/app/android/app/google-services.json @@ -12,7 +12,20 @@ "package_name": "com.canopas.cloud_gallery" } }, - "oauth_client": [], + "oauth_client": [ + { + "client_id": "64221198282-3eg7r09fsl1u3s9tge7ud1206q18pkf7.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.canopas.cloud_gallery", + "certificate_hash": "38887addbb77aaeba38c77a211469aafe02b2b41" + } + }, + { + "client_id": "64221198282-3pk3g95eutmuj2u4h45ptorsbb64g3og.apps.googleusercontent.com", + "client_type": 3 + } + ], "api_key": [ { "current_key": "AIzaSyABDkRcwTA2gwgjBtx5GGNLgAsCHKY7Rpc" @@ -20,7 +33,19 @@ ], "services": { "appinvite_service": { - "other_platform_oauth_client": [] + "other_platform_oauth_client": [ + { + "client_id": "64221198282-3pk3g95eutmuj2u4h45ptorsbb64g3og.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "64221198282-h8h8gjo3991iijeg2agdkmfh6tr014nq.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "com.canopas.cloudGallery" + } + } + ] } } } diff --git a/app/android/app/local.properties b/app/android/app/local.properties new file mode 100644 index 0000000..654aec0 --- /dev/null +++ b/app/android/app/local.properties @@ -0,0 +1,8 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Wed Jan 17 14:17:41 IST 2024 +sdk.dir=/Users/pratikcanopas/Library/Android/sdk diff --git a/app/android/build.gradle b/app/android/build.gradle index e83fb5d..b0d5826 100644 --- a/app/android/build.gradle +++ b/app/android/build.gradle @@ -7,6 +7,7 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "com.google.gms:google-services:4.4.0" } } diff --git a/app/ios/Runner/GoogleService-Info.plist b/app/ios/Runner/GoogleService-Info.plist index da91891..caae6a0 100644 --- a/app/ios/Runner/GoogleService-Info.plist +++ b/app/ios/Runner/GoogleService-Info.plist @@ -2,6 +2,10 @@ + CLIENT_ID + 64221198282-h8h8gjo3991iijeg2agdkmfh6tr014nq.apps.googleusercontent.com + REVERSED_CLIENT_ID + com.googleusercontent.apps.64221198282-h8h8gjo3991iijeg2agdkmfh6tr014nq API_KEY AIzaSyDOoeWHX2RlxHcQ_QUHvR-tZJk_RsFluwY GCM_SENDER_ID diff --git a/app/ios/Runner/Info.plist b/app/ios/Runner/Info.plist index 65b37b6..cee9707 100644 --- a/app/ios/Runner/Info.plist +++ b/app/ios/Runner/Info.plist @@ -12,6 +12,19 @@ $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 + GIDClientID + 64221198282-h8h8gjo3991iijeg2agdkmfh6tr014nq.apps.googleusercontent.com + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + com.googleusercontent.apps.64221198282-h8h8gjo3991iijeg2agdkmfh6tr014nq + + + CFBundleName cloud_gallery CFBundlePackageType diff --git a/app/lib/main.dart b/app/lib/main.dart index 7c563a7..bd128c1 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -5,7 +5,9 @@ import 'ui/app.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(); + final container = ProviderContainer(); runApp(UncontrolledProviderScope( container: container, child: const CloudGalleryApp())); From 49605085dd639d9af11cd456e74e7ed36e555c5b Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 16:19:16 +0530 Subject: [PATCH 5/8] Set set up firebase --- .idea/libraries/Dart_Packages.xml | 30 ++++++++++++++++++--- .idea/libraries/Flutter_Plugins.xml | 2 ++ data/lib/services/auth_service.dart | 2 +- data/lib/services/google_drive_service.dart | 18 ++++++++----- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index ad81025..d8a0ed1 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -226,6 +226,27 @@ + + + + + + + + + + + + + + + + + + @@ -362,8 +383,8 @@ - @@ -384,8 +405,8 @@ - @@ -420,7 +441,6 @@ - @@ -733,6 +753,9 @@ + + + @@ -759,7 +782,6 @@ - diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index c4e0028..4c421aa 100644 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -5,6 +5,8 @@ + + diff --git a/data/lib/services/auth_service.dart b/data/lib/services/auth_service.dart index 3dc66ef..6753c34 100644 --- a/data/lib/services/auth_service.dart +++ b/data/lib/services/auth_service.dart @@ -5,7 +5,7 @@ import 'package:googleapis/drive/v3.dart' as drive; final googleSignInProvider = Provider( (ref) => GoogleSignIn( scopes: [ - drive.DriveApi.driveFileScope, + drive.DriveApi.driveScope, ], ), ); diff --git a/data/lib/services/google_drive_service.dart b/data/lib/services/google_drive_service.dart index 0db8117..ff26b20 100644 --- a/data/lib/services/google_drive_service.dart +++ b/data/lib/services/google_drive_service.dart @@ -1,5 +1,4 @@ import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:googleapis/drive/v3.dart' as drive; @@ -15,14 +14,21 @@ class GoogleDriveService { const GoogleDriveService(this._googleSignIn); Future getDriveFiles() async { + print("Getting drive files.."); if (_googleSignIn.currentUser != null) { + print("currentUser: ${_googleSignIn.currentUser}"); final client = await _googleSignIn.authenticatedClient(); - if (client == null) return; - final driveApi = drive.DriveApi(client); - final files = await driveApi.files.list(); - if (kDebugMode) { - print(files); + print("client: $client"); + print("client is null: ${client == null}"); + final driveApi = drive.DriveApi(client!); + try { + final files = await driveApi.files.list(); + print(files.toJson()); + } catch (e) { + print("Error: $e"); } + } else { + print("currentUser: null"); } } } From 8f08314291ae953e50f1e6901b135cb75da6e7ba Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 19:13:10 +0530 Subject: [PATCH 6/8] Implement google sign in --- app/lib/firebase_options.dart | 70 +++++++++++++++++++++++++++++++++++ app/lib/main.dart | 5 ++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 app/lib/firebase_options.dart diff --git a/app/lib/firebase_options.dart b/app/lib/firebase_options.dart new file mode 100644 index 0000000..e12dc21 --- /dev/null +++ b/app/lib/firebase_options.dart @@ -0,0 +1,70 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members +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.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyABDkRcwTA2gwgjBtx5GGNLgAsCHKY7Rpc', + appId: '1:64221198282:android:64782148b88407396e8133', + messagingSenderId: '64221198282', + projectId: 'cloud-gallery-auth', + storageBucket: 'cloud-gallery-auth.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyDOoeWHX2RlxHcQ_QUHvR-tZJk_RsFluwY', + appId: '1:64221198282:ios:fcb315ff1f4bb4a66e8133', + messagingSenderId: '64221198282', + projectId: 'cloud-gallery-auth', + storageBucket: 'cloud-gallery-auth.appspot.com', + androidClientId: '64221198282-3eg7r09fsl1u3s9tge7ud1206q18pkf7.apps.googleusercontent.com', + iosClientId: '64221198282-h8h8gjo3991iijeg2agdkmfh6tr014nq.apps.googleusercontent.com', + iosBundleId: 'com.canopas.cloudGallery', + ); +} diff --git a/app/lib/main.dart b/app/lib/main.dart index bd128c1..6581d8a 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:cloud_gallery/firebase_options.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -6,7 +7,9 @@ import 'ui/app.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp(); + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); final container = ProviderContainer(); runApp(UncontrolledProviderScope( From 94179af4d004fe85b10c8614a182d7f311291b2e Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 19:20:00 +0530 Subject: [PATCH 7/8] Remove unused code --- app/lib/ui/flow/main/main_screen.dart | 27 +--- .../ui/flow/main/main_screen_view_model.dart | 40 ------ .../main/main_screen_view_model.freezed.dart | 129 ------------------ 3 files changed, 4 insertions(+), 192 deletions(-) delete mode 100644 app/lib/ui/flow/main/main_screen_view_model.dart delete mode 100644 app/lib/ui/flow/main/main_screen_view_model.freezed.dart diff --git a/app/lib/ui/flow/main/main_screen.dart b/app/lib/ui/flow/main/main_screen.dart index 3469ea8..16305e4 100644 --- a/app/lib/ui/flow/main/main_screen.dart +++ b/app/lib/ui/flow/main/main_screen.dart @@ -1,6 +1,4 @@ -import 'package:cloud_gallery/ui/flow/main/main_screen_view_model.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @@ -13,26 +11,9 @@ class _MainScreenState extends State { @override Widget build(BuildContext context) { return const Scaffold( - body: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [Button()], - ), - )); - } -} - -class Button extends ConsumerWidget { - const Button({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final notifier = ref.read(mainScreenViewNotifierProvider.notifier); - return TextButton( - onPressed: () { - notifier.getFiles(); - }, - child: const Text("Get DriveFiles")); + body: Center( + child: Text('Home Screen'), + ), + ); } } diff --git a/app/lib/ui/flow/main/main_screen_view_model.dart b/app/lib/ui/flow/main/main_screen_view_model.dart deleted file mode 100644 index 883cd52..0000000 --- a/app/lib/ui/flow/main/main_screen_view_model.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:data/services/auth_service.dart'; -import 'package:data/services/google_drive_service.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'main_screen_view_model.freezed.dart'; - -final mainScreenViewNotifierProvider = StateNotifierProvider.autoDispose< - MainScreenViewNotifier, MainScreenViewState>( - (ref) => MainScreenViewNotifier( - ref.watch(authServiceProvider), - ref.read(googleDriveServiceProvider) - ), -); - -class MainScreenViewNotifier extends StateNotifier { - MainScreenViewNotifier( - this._authService, - this._googleDriveService, - ) : super(const MainScreenViewState()); - - final AuthService _authService; - final GoogleDriveService _googleDriveService; - - Future getFiles() async { - try { - await _authService.signInWithGoogle(); - await _googleDriveService.getDriveFiles(); - } catch (error) { - state = state.copyWith(error: error); - } - } -} - -@freezed -class MainScreenViewState with _$MainScreenViewState { - const factory MainScreenViewState({ - Object? error, - }) = _MainScreenViewState; -} diff --git a/app/lib/ui/flow/main/main_screen_view_model.freezed.dart b/app/lib/ui/flow/main/main_screen_view_model.freezed.dart deleted file mode 100644 index 9be4419..0000000 --- a/app/lib/ui/flow/main/main_screen_view_model.freezed.dart +++ /dev/null @@ -1,129 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'main_screen_view_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); - -/// @nodoc -mixin _$MainScreenViewState { - Object? get error => throw _privateConstructorUsedError; - - @JsonKey(ignore: true) - $MainScreenViewStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $MainScreenViewStateCopyWith<$Res> { - factory $MainScreenViewStateCopyWith( - MainScreenViewState value, $Res Function(MainScreenViewState) then) = - _$MainScreenViewStateCopyWithImpl<$Res, MainScreenViewState>; - @useResult - $Res call({Object? error}); -} - -/// @nodoc -class _$MainScreenViewStateCopyWithImpl<$Res, $Val extends MainScreenViewState> - implements $MainScreenViewStateCopyWith<$Res> { - _$MainScreenViewStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? error = freezed, - }) { - return _then(_value.copyWith( - error: freezed == error ? _value.error : error, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$MainScreenViewStateImplCopyWith<$Res> - implements $MainScreenViewStateCopyWith<$Res> { - factory _$$MainScreenViewStateImplCopyWith(_$MainScreenViewStateImpl value, - $Res Function(_$MainScreenViewStateImpl) then) = - __$$MainScreenViewStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({Object? error}); -} - -/// @nodoc -class __$$MainScreenViewStateImplCopyWithImpl<$Res> - extends _$MainScreenViewStateCopyWithImpl<$Res, _$MainScreenViewStateImpl> - implements _$$MainScreenViewStateImplCopyWith<$Res> { - __$$MainScreenViewStateImplCopyWithImpl(_$MainScreenViewStateImpl _value, - $Res Function(_$MainScreenViewStateImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? error = freezed, - }) { - return _then(_$MainScreenViewStateImpl( - error: freezed == error ? _value.error : error, - )); - } -} - -/// @nodoc - -class _$MainScreenViewStateImpl implements _MainScreenViewState { - const _$MainScreenViewStateImpl({this.error}); - - @override - final Object? error; - - @override - String toString() { - return 'MainScreenViewState(error: $error)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MainScreenViewStateImpl && - const DeepCollectionEquality().equals(other.error, error)); - } - - @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(error)); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$MainScreenViewStateImplCopyWith<_$MainScreenViewStateImpl> get copyWith => - __$$MainScreenViewStateImplCopyWithImpl<_$MainScreenViewStateImpl>( - this, _$identity); -} - -abstract class _MainScreenViewState implements MainScreenViewState { - const factory _MainScreenViewState({final Object? error}) = - _$MainScreenViewStateImpl; - - @override - Object? get error; - @override - @JsonKey(ignore: true) - _$$MainScreenViewStateImplCopyWith<_$MainScreenViewStateImpl> get copyWith => - throw _privateConstructorUsedError; -} From aa779c063b2f5e76f659b688ca0ed4757211ce59 Mon Sep 17 00:00:00 2001 From: Pratik-canopas Date: Wed, 17 Jan 2024 19:20:18 +0530 Subject: [PATCH 8/8] Remove unused code --- data/.flutter-plugins-dependencies | 2 +- data/lib/services/google_drive_service.dart | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index 4c66174..432e794 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-17 12:29:13.396414","version":"3.16.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-17 19:19:20.833539","version":"3.16.7"} \ No newline at end of file diff --git a/data/lib/services/google_drive_service.dart b/data/lib/services/google_drive_service.dart index ff26b20..8e26ae9 100644 --- a/data/lib/services/google_drive_service.dart +++ b/data/lib/services/google_drive_service.dart @@ -14,21 +14,12 @@ class GoogleDriveService { const GoogleDriveService(this._googleSignIn); Future getDriveFiles() async { - print("Getting drive files.."); if (_googleSignIn.currentUser != null) { - print("currentUser: ${_googleSignIn.currentUser}"); final client = await _googleSignIn.authenticatedClient(); - print("client: $client"); - print("client is null: ${client == null}"); final driveApi = drive.DriveApi(client!); - try { - final files = await driveApi.files.list(); - print(files.toJson()); - } catch (e) { - print("Error: $e"); - } - } else { - print("currentUser: null"); + await driveApi.files.list(); + + ///TODO: Convert File to custom object } } }