Skip to content

Commit

Permalink
Implement core function for google sign-n
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k committed Jan 17, 2024
1 parent 08b8164 commit 76892d1
Show file tree
Hide file tree
Showing 16 changed files with 1,116 additions and 48 deletions.
788 changes: 788 additions & 0 deletions .idea/libraries/Dart_Packages.xml

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -49,7 +43,6 @@ SPEC CHECKSUMS:
GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842
GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae
GTMSessionFetcher: 41b9ef0b4c08a6db4b7eb51a21ae5183ec99a2c8
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695

PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189

Expand Down
4 changes: 3 additions & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
24 changes: 22 additions & 2 deletions app/lib/ui/flow/main/main_screen.dart
Original file line number Diff line number Diff line change
@@ -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});
Expand All @@ -12,7 +14,25 @@ class _MainScreenState extends State<HomeScreen> {
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"));
}
}
40 changes: 40 additions & 0 deletions app/lib/ui/flow/main/main_screen_view_model.dart
Original file line number Diff line number Diff line change
@@ -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<MainScreenViewState> {
MainScreenViewNotifier(
this._authService,
this._googleDriveService,
) : super(const MainScreenViewState());

final AuthService _authService;
final GoogleDriveService _googleDriveService;

Future<void> 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;
}
129 changes: 129 additions & 0 deletions app/lib/ui/flow/main/main_screen_view_model.freezed.dart
Original file line number Diff line number Diff line change
@@ -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>(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<MainScreenViewState> 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;
}
19 changes: 0 additions & 19 deletions app/lib/ui/flow/settings /settings_screen.dart

This file was deleted.

11 changes: 0 additions & 11 deletions app/lib/ui/navigation/app_router.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -9,21 +8,11 @@ class AppRouter {
builder: (context) => const HomeScreen(),
);

static AppRoute get settings => AppRoute(
AppRoutePath.settings,
builder: (context) => const SettingsScreen(),
);

static final routes = <GoRoute>[
home.goRoute,
GoRoute(
path: AppRoutePath.settings,
builder: (context, state) => state.widget(context),
),
];
}

class AppRoutePath {
static const home = '/';
static const settings = '/settings';
}
24 changes: 20 additions & 4 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -301,15 +309,15 @@ packages:
source: sdk
version: "0.0.0"
freezed:
dependency: "direct dev"
dependency: "direct main"
description:
name: freezed
sha256: "6c5031daae12c7072b3a87eff98983076434b4889ef2a44384d0cae3f82372ba"
url: "https://pub.dev"
source: hosted
version: "2.4.6"
freezed_annotation:
dependency: transitive
dependency: "direct main"
description:
name: freezed_annotation
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -43,7 +47,8 @@ dev_dependencies:

# code generation
build_runner: ^2.3.3
freezed: ^2.4.6




flutter:
Expand Down
Loading

0 comments on commit 76892d1

Please sign in to comment.