LCOV - code coverage report
Current view: top level - utils - red_fire_locator.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 6 20 30.0 %
Date: 2022-03-03 12:16:56 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:io';
       2             : 
       3             : import 'package:firebase_auth/firebase_auth.dart';
       4             : import 'package:flutter/foundation.dart';
       5             : import 'package:flutter/material.dart';
       6             : import 'package:google_sign_in/google_sign_in.dart';
       7             : 
       8             : import '../../utils.dart';
       9             : import '../auth/services/auth_service.dart';
      10             : import '../database/services/database_service.dart';
      11             : import '../networking/services/http_service.dart';
      12             : import '../platform/plugins/wrappers/apple_signin_wrapper.dart';
      13             : import '../platform/services/platform_service.dart';
      14             : import '../types/redux_action.dart';
      15             : 
      16             : class RedFireLocator {
      17             :   ////////////////////////////////////////////////////
      18             :   /// Config
      19             :   ////////////////////////////////////////////////////
      20             : 
      21           0 :   static RedFireConfig getConfig() => _config!;
      22           2 :   static void provideConfig(RedFireConfig config) => _config = config;
      23             : 
      24             :   ////////////////////////////////////////////////////
      25             :   /// Services
      26             :   ////////////////////////////////////////////////////
      27             :   // TODO: fix this - we only need to create a service once, not every time get... is called
      28             :   // --> Change ?? to ??= and write a test
      29           6 :   static AuthService getAuthService() =>
      30             :       _authService ??
      31             :       // Create an AuthService with only the relevant auth providers
      32           0 :       AuthService(
      33           0 :           firebase: FirebaseAuth.instance,
      34           0 :           google: (kIsWeb || Platform.isAndroid)
      35           0 :               ? GoogleSignIn(
      36           0 :                   scopes: <String>['email'], clientId: _config?.auth.clientId)
      37             :               : null,
      38             :           apple:
      39           0 :               (kIsWeb || Platform.isAndroid) ? null : SignInWithAppleWrapper());
      40           0 :   static DatabaseService getDatabaseService() =>
      41           0 :       _databaseService ?? DatabaseService();
      42           2 :   static PlatformService getPlatformService() =>
      43           0 :       _platformService ?? PlatformService();
      44           0 :   static HttpService getHttpService() => _httpService ?? HttpService();
      45           4 :   static List<ReduxAction> get getOnSignInActions => _onSignInActions ?? [];
      46             : 
      47             :   // Provide one or more
      48           8 :   static void provide(
      49             :       {AuthService? authService,
      50             :       DatabaseService? databaseService,
      51             :       PlatformService? platformService,
      52             :       HttpService? httpService}) {
      53             :     _authService = authService;
      54             :     _databaseService = databaseService;
      55             :     _platformService = platformService;
      56             :     _httpService = httpService;
      57             :   }
      58             : 
      59           0 :   static void provideAll(
      60             :       {required AuthService authService,
      61             :       required DatabaseService databaseService,
      62             :       required PlatformService platformService,
      63             :       required HttpService httpService}) {
      64             :     _authService = authService;
      65             :     _databaseService = databaseService;
      66             :     _platformService = platformService;
      67             :     _httpService = httpService;
      68             :   }
      69             : 
      70           0 :   static void provideOnSignInActions(List<ReduxAction>? onSignInActions) =>
      71             :       _onSignInActions = onSignInActions;
      72             : 
      73             :   static RedFireConfig? _config;
      74             :   static AuthService? _authService;
      75             :   static DatabaseService? _databaseService;
      76             :   static PlatformService? _platformService;
      77             :   static HttpService? _httpService;
      78             :   static List<ReduxAction>? _onSignInActions;
      79             : 
      80             :   ////////////////////////////////////////////////////
      81             :   /// Controllers
      82             :   ////////////////////////////////////////////////////
      83             : 
      84           0 :   static void provideEmailTextFieldController(
      85             :       TextEditingController? controller) {
      86             :     _emailTextFieldController = controller;
      87             :   }
      88             : 
      89           1 :   static TextEditingController? getEmailTextFieldController() =>
      90             :       _emailTextFieldController;
      91             : 
      92             :   static TextEditingController? _emailTextFieldController;
      93             : }

Generated by: LCOV version 1.13