Skip to content

Commit

Permalink
[Parent][RC 3.2.3] Hide qr pairing option with student flag (#972)
Browse files Browse the repository at this point in the history
* [Parent][RC 3.2.3] Hide qr pairing option with student flag

* add remote config mocking for qr util tests
  • Loading branch information
TrevorNeedham authored Sep 3, 2020
1 parent d4a3993 commit 9e835ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/flutter_parent/lib/screens/pairing/pairing_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:flutter_parent/screens/pairing/pairing_code_dialog.dart';
import 'package:flutter_parent/utils/design/canvas_icons.dart';
import 'package:flutter_parent/utils/design/parent_colors.dart';
import 'package:flutter_parent/utils/quick_nav.dart';
import 'package:flutter_parent/utils/remote_config_utils.dart';
import 'package:flutter_parent/utils/service_locator.dart';
import 'package:flutter_svg/flutter_svg.dart';

Expand All @@ -37,7 +38,7 @@ class PairingUtil {
Text(L10n(context).addStudentWith, style: Theme.of(context).textTheme.caption),
SizedBox(height: 12),
_pairingCode(context, onSuccess),
if (ApiPrefs.getCameraCount() != 0) _qrCode(context, onSuccess),
if (_isQRPairingEnabled()) _qrCode(context, onSuccess),
],
);
},
Expand Down Expand Up @@ -88,3 +89,8 @@ class PairingUtil {
class StudentAddedNotifier extends ChangeNotifier {
void notify() => notifyListeners();
}

bool _isQRPairingEnabled() {
return RemoteConfigUtils.getStringValue(RemoteConfigParams.QR_PAIR_OBSERVER_ENABLED).toLowerCase() == 'true' &&
(ApiPrefs.getCameraCount() != null && ApiPrefs.getCameraCount() != 0);
}
3 changes: 3 additions & 0 deletions apps/flutter_parent/lib/utils/remote_config_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum RemoteConfigParams {
MOBILE_VERIFY_BETA_ENABLED,
QR_LOGIN_ENABLED_PARENT,
QR_ACCOUNT_CREATION_ENABLED_PARENT,
QR_PAIR_OBSERVER_ENABLED,
}

class RemoteConfigUtils {
Expand Down Expand Up @@ -123,6 +124,8 @@ class RemoteConfigUtils {
return 'mobile_verify_beta_enabled';
case RemoteConfigParams.QR_ACCOUNT_CREATION_ENABLED_PARENT:
return 'qr_account_creation_enabled';
case RemoteConfigParams.QR_PAIR_OBSERVER_ENABLED:
return 'qr_pair_observer_enabled';
default:
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';

import '../../utils/accessibility_utils.dart';
import '../../utils/platform_config.dart';
import '../../utils/test_app.dart';
import '../../utils/test_helpers/mock_helpers.dart';

Expand All @@ -34,7 +35,9 @@ void main() {
locator.registerLazySingleton<QuickNav>(() => nav);
});

setUp(() {
setUp(() async {
final mockRemoteConfig = setupMockRemoteConfig(valueSettings: {'qr_pair_observer_enabled': 'true'});
await setupPlatformChannels(config: PlatformConfig(initRemoteConfig: mockRemoteConfig));
reset(nav);
});

Expand Down

0 comments on commit 9e835ed

Please sign in to comment.