-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update firebase_remote_config * Initialize firebase configuration * Perform a ghost sign in if the app is in review * Update base URL * Fix formatting
- Loading branch information
1 parent
9bafe3d
commit 23a217d
Showing
12 changed files
with
199 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,4 @@ app.*.map.json | |
.fvmrc | ||
.vscode/settings.json | ||
devtools_options.yaml | ||
lib/versioning/build_version.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
targets: | ||
$default: | ||
builders: | ||
build_version: | ||
options: | ||
output: lib/versioning/build_version.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'remote_config.freezed.dart'; | ||
part 'remote_config.g.dart'; | ||
|
||
@freezed | ||
class RemoteConfig with _$RemoteConfig { | ||
factory RemoteConfig({ | ||
@JsonKey(name: 'app_version') required String appVersion, | ||
@JsonKey(name: 'is_in_review') required bool isInReview, | ||
}) = _RemoteConfig; | ||
|
||
factory RemoteConfig.fromJson(Map<String, dynamic> json) => | ||
_$RemoteConfigFromJson(json); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:fluttercon/common/data/models/models.dart'; | ||
import 'package:fluttercon/common/utils/env/flavor_config.dart'; | ||
import 'package:fluttercon/common/utils/network.dart'; | ||
import 'package:google_sign_in/google_sign_in.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
@@ -18,6 +19,22 @@ class AuthRepository { | |
], | ||
); | ||
|
||
Future<AuthResult> ghostSignIn() async { | ||
try { | ||
final response = await _networkUtil.postReq( | ||
'${FlutterConConfig.instance!.values.baseUrl}/api/v1/login', | ||
body: { | ||
'email': '[email protected]', | ||
'password': 'password', | ||
}, | ||
); | ||
|
||
return AuthResult.fromJson(response); | ||
} catch (e) { | ||
rethrow; | ||
} | ||
} | ||
|
||
Future<String> signInWithGoogle() async { | ||
try { | ||
final googleSignInAccount = await _googleSignIn.signIn(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:firebase_remote_config/firebase_remote_config.dart'; | ||
import 'package:fluttercon/common/data/models/remote_config.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
||
@singleton | ||
class FirebaseRepository { | ||
final remoteConfig = FirebaseRemoteConfig.instance; | ||
|
||
Future<void> init() async { | ||
await remoteConfig.fetchAndActivate(); | ||
} | ||
|
||
RemoteConfig getConfig() { | ||
final config = remoteConfig.getValue('dev_flutterconke_fluttercon'); | ||
|
||
return RemoteConfig.fromJson( | ||
json.decode( | ||
config.asString(), | ||
) as Map<String, dynamic>, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:fluttercon/common/repository/auth_repository.dart'; | ||
import 'package:fluttercon/common/repository/hive_repository.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'ghost_sign_in_state.dart'; | ||
part 'ghost_sign_in_cubit.freezed.dart'; | ||
|
||
class GhostSignInCubit extends Cubit<GhostSignInState> { | ||
GhostSignInCubit({ | ||
required AuthRepository authRepository, | ||
required HiveRepository hiveRepository, | ||
}) : super(const GhostSignInState.initial()) { | ||
_authRepository = authRepository; | ||
_hiveRepository = hiveRepository; | ||
} | ||
|
||
late AuthRepository _authRepository; | ||
late HiveRepository _hiveRepository; | ||
|
||
Future<void> signIn() async { | ||
emit(const GhostSignInState.loading()); | ||
try { | ||
final authResult = await _authRepository.ghostSignIn(); | ||
_hiveRepository | ||
..persistToken(authResult.token) | ||
..persistUser(authResult.user); | ||
|
||
emit(const GhostSignInState.loaded()); | ||
} catch (e) { | ||
emit(GhostSignInState.error(e.toString())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
part of 'ghost_sign_in_cubit.dart'; | ||
|
||
@freezed | ||
class GhostSignInState with _$GhostSignInState { | ||
const factory GhostSignInState.initial() = _Initial; | ||
const factory GhostSignInState.loading() = _Loading; | ||
const factory GhostSignInState.loaded() = _Loaded; | ||
const factory GhostSignInState.error(String message) = _Error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters