Skip to content
Merged
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ to your application, add this dependency to your `pubspec.yaml` file:

```yaml
flutter_controls_core:
git:
url: https://github.com/fermi-ad/flutter-controls-core.git
ref: main
git:
url: https://github.com/fermi-ad/flutter-controls-core.git
tag_pattern: v{{version}}
version: ^1.2.0
```

_NOTE:_ This project is under very active development so calling this the
Expand Down
35 changes: 14 additions & 21 deletions lib/src/app_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,14 @@ final class _DrawerHeaderState extends State<_DrawerHeader> {
null,
),

(null, true) => _buildAuthHeader(
Icons.no_accounts_sharp,
"Unauthorized",
(
(null, true) =>
_buildAuthHeader(Icons.no_accounts_sharp, "Unauthorized", (
"Login",
() => closeDrawerThen(() {
infoBox(context, "Log in", "Contacting KeyCloak ...");
AuthService.requestLogin(context);
}),
),
_buildMissingRolesWarning(context, widget.neededRoles),
),
), _buildMissingRolesWarning(context, widget.neededRoles)),

(UserInfo user, true) => _buildAuthHeader(
Icons.account_circle,
Expand Down Expand Up @@ -439,35 +435,32 @@ final class StandardApp<T extends ChangeNotifier> extends StatelessWidget {
// Build the base scaffold for the application. We don't just return it
// because it may need to be "wrapped" in other widgets.

Widget tmpScaffold = Scaffold(
Widget scaffold = Scaffold(
appBar: appBar,
body: body,
drawer: _Drawer(drawerContent, authInfo, _neededRoles),
floatingActionButton: floatingActionButton,
);

// Wrap the scaffold with the AuthService if authentication is being used.
// This is done here so that the AuthService is below the providers and
// global state. This is important because when you log in and log out, the
// providers and global state will reinitialize.
// Iterate over the list of providers, wrapping -- and eventually returning
// -- the accumulated widgets around the base scaffold.

scaffold = providers.fold<Widget>(scaffold, (w, p) => p(child: w));

// Wrap with the AuthService if authentication is being used. This is done
// here so that the providers can use the AuthService to access the current
// user and their JWT.

if (authInfo != null) {
tmpScaffold = AuthService(authInfo: authInfo!, child: tmpScaffold);
scaffold = AuthService(authInfo: authInfo!, child: scaffold);
}

// Now wrap the scaffold with any global state used by the application.

if (model != null) {
tmpScaffold = _GlobalStateProvider<T>(model: model!, child: tmpScaffold);
scaffold = _GlobalStateProvider<T>(model: model!, child: scaffold);
}

// Iterate over the list of providers, wrapping -- and eventually returning
// -- the accumulated widgets. We need the AuthService to be below the
// providers because when you log in and log out, the providers will
// restart their data aquisition.

final scaffold = providers.fold<Widget>(tmpScaffold, (w, p) => p(child: w));

final theme = _resolveTheme(useBison);

return MaterialApp(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_controls_core
description: A Flutter package to write Fermilab applications.
version: 1.2.4
version: 1.2.5
publish_to: none

environment:
Expand Down
Loading