Skip to content

Commit

Permalink
Support dismissing flutter web warning
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Jul 1, 2024
1 parent f9ab2a3 commit 7194f75
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/redux/app/app_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class DismissTwoYearReviewAppPermanently implements PersistUI, PersistPrefs {}

class DismissTaskExtensionBanner implements PersistUI, PersistPrefs {}

class DismissFlutterWebWarning implements PersistUI {}

class ViewMainScreen {
ViewMainScreen({this.addDelay = false});

Expand Down
8 changes: 8 additions & 0 deletions lib/redux/ui/ui_reducer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ UIState uiReducer(UIState state, dynamic action) {
..filter = filterReducer(state.filter, action)
..filterClearedAt = filterClearedAtReducer(state.filterClearedAt, action)
..lastActivityAt = lastActivityReducer(state.lastActivityAt, action)
..dismissedFlutterWebWarning = dismissedFlutterWebWarningReducer(
state.dismissedFlutterWebWarning, action)
..selectedCompanyIndex =
selectedCompanyIndexReducer(state.selectedCompanyIndex, action)
..previousRoute = state.currentRoute == currentRoute
Expand Down Expand Up @@ -192,6 +194,12 @@ Reducer<int> lastActivityReducer = combineReducers([
}),
]);

Reducer<bool> dismissedFlutterWebWarningReducer = combineReducers([
TypedReducer<bool, DismissFlutterWebWarning>((state, action) {
return true;
}),
]);

Reducer<String?> filterReducer = combineReducers([
TypedReducer<String?, FilterCompany>((filter, action) {
return action.filter;
Expand Down
4 changes: 4 additions & 0 deletions lib/redux/ui/ui_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {
lastActivityAt: 0,
currentRoute: currentRoute ?? LoginScreen.route,
previousRoute: '',
dismissedFlutterWebWarning: false,
previewStack: BuiltList<EntityType>(),
filterStack: BuiltList<BaseEntity>(),
dashboardUIState: DashboardUIState(),
Expand Down Expand Up @@ -126,6 +127,8 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {

String get previousRoute;

bool get dismissedFlutterWebWarning;

EntityType? get loadingEntityType;

BuiltList<EntityType> get previewStack;
Expand Down Expand Up @@ -295,6 +298,7 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {
// ignore: unused_element
static void _initializeBuilder(UIStateBuilder builder) => builder
..lastActivityAt = 0
..dismissedFlutterWebWarning = false
..filterStack.replace(BuiltList<BaseEntity>());

static Serializer<UIState> get serializer => _$uIStateSerializer;
Expand Down
25 changes: 25 additions & 0 deletions lib/redux/ui/ui_state.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/ui/app/important_message_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class _ImportantMessageBannerState extends State<ImportantMessageBanner> {

if (kIsWeb &&
!_dismissedMessage.containsKey(MESSAGE_TYPE_FLUTTER_WEB) &&
!state.uiState.dismissedFlutterWebWarning &&
!state.isDemo) {
message = localization.flutterWebWarning;
messageType = MESSAGE_TYPE_FLUTTER_WEB;
Expand Down Expand Up @@ -180,6 +181,9 @@ class _ImportantMessageBannerState extends State<ImportantMessageBanner> {
color: Colors.white,
onPressed: () {
setState(() => _dismissedMessage[messageType!] = true);
if (messageType == MESSAGE_TYPE_FLUTTER_WEB) {
store.dispatch(DismissFlutterWebWarning());
}
},
),
],
Expand Down

0 comments on commit 7194f75

Please sign in to comment.