Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Match TOTP modal to SMS/Voice modal #133

Draft
wants to merge 5 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions lib/controllers/user_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ class UserProvider extends ChangeNotifier {
notifyListeners();
}

void login() async {
await auth0Web.loginWithRedirect(redirectUrl: redirectUri);
}

Future<bool> isLoggedIn() async =>
await auth0Web.hasValidCredentials();

Future<Credentials> currentCredentials() async =>
await auth0Web.credentials();

Future<void> logout() => auth0Web.logout(
federated: false,
returnToUrl: 'https://sandbox.account.lacity.gov/'
Expand Down
70 changes: 70 additions & 0 deletions lib/utils/BaseMFADialogState.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';

import 'constants.dart';

abstract class BaseDialogState<T extends StatefulWidget> extends State<T> {

List<Widget> get dialogNext => [];

Check warning on line 7 in lib/utils/BaseMFADialogState.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils/BaseMFADialogState.dart#L7

Added line #L7 was not covered by tests
Widget get dialogBody;
int pageIndex = 0;
String errMsg = '';
bool obscurePassword = true;
late bool _isSmallScreen;

Widget get dialogClose => IconButton(
alignment: Alignment.centerLeft,
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(Icons.close),
);

Widget get dialogBack => TextButton(
onPressed: () {
setState(() {
pageIndex -= 1;

Check warning on line 25 in lib/utils/BaseMFADialogState.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils/BaseMFADialogState.dart#L23-L25

Added lines #L23 - L25 were not covered by tests
});
},
child: const Text('Back'),
);

void navigateToNextPage() {
if (pageIndex <= 2) {
setState(() {
pageIndex += 1;
});
} else {
Navigator.pop(context);

Check warning on line 37 in lib/utils/BaseMFADialogState.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils/BaseMFADialogState.dart#L37

Added line #L37 was not covered by tests
}
}

Widget modalBody(final Widget body) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
dialogClose,
_isSmallScreen ? Expanded(child: body) : body,
if (_isSmallScreen)
Row(

Check warning on line 48 in lib/utils/BaseMFADialogState.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils/BaseMFADialogState.dart#L48

Added line #L48 was not covered by tests
mainAxisAlignment: MainAxisAlignment.end,
children: pageIndex == 0 ? [dialogNext[pageIndex]] : [dialogBack, dialogNext[pageIndex]],

Check warning on line 50 in lib/utils/BaseMFADialogState.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils/BaseMFADialogState.dart#L50

Added line #L50 was not covered by tests
),
],
);

@override
Widget build(final BuildContext context) {
final double screenWidth = MediaQuery.of(context).size.width;
final bool isSmallScreen = screenWidth < smallScreen;

_isSmallScreen = isSmallScreen;

return isSmallScreen
? Dialog.fullscreen(child: dialogBody)

Check warning on line 63 in lib/utils/BaseMFADialogState.dart

View check run for this annotation

Codecov / codecov/patch

lib/utils/BaseMFADialogState.dart#L63

Added line #L63 was not covered by tests
: AlertDialog(
content: dialogBody,
actionsAlignment: MainAxisAlignment.end,
actions: pageIndex == 0 ? [dialogNext[pageIndex]] : [dialogBack, dialogNext[pageIndex]],
);
}
}
Loading
Loading