@@ -27,7 +27,7 @@ enum Actions { increment, setText, setError }
2727
2828AppState appReducer (AppState state, dynamic action) {
2929 if (action is PageLoadAction ) {
30- var sessionId = SessionStore .get ( " sessionId" ) ;
30+ var sessionId = SessionStore .sessionId;
3131 return state.copyWith (
3232 pageUri: action.pageUri,
3333 assetsDir: action.assetsDir,
@@ -95,7 +95,9 @@ AppState appReducer(AppState state, dynamic action) {
9595 windowLeft: wmd.left != null ? wmd.left.toString () : "" ,
9696 isPWA: isProgressiveWebApp ().toString (),
9797 isWeb: kIsWeb.toString (),
98- platform: defaultTargetPlatform.name.toLowerCase ());
98+ isDebug: kDebugMode.toString (),
99+ platform: defaultTargetPlatform.name.toLowerCase (),
100+ platformBrightness: state.displayBrightness.name.toString ());
99101
100102 action.server.connect (address: state.pageUri! .toString ());
101103 });
@@ -137,6 +139,28 @@ AppState appReducer(AppState state, dynamic action) {
137139
138140 return state.copyWith (controls: controls);
139141 } else if (action is PageBrightnessChangeAction ) {
142+ //
143+ // platform brightness changed
144+ //
145+ debugPrint ("New platform brightness: ${action .brightness .name }" );
146+
147+ var page = state.controls["page" ];
148+ var controls = Map .of (state.controls);
149+ if (page != null && ! state.isLoading) {
150+ var pageAttrs = Map .of (page.attrs);
151+ pageAttrs["platformBrightness" ] = action.brightness.name.toString ();
152+
153+ List <Map <String , String >> props = [
154+ {"i" : "page" , "platformBrightness" : action.brightness.name.toString ()},
155+ ];
156+
157+ controls[page.id] = page.copyWith (attrs: pageAttrs);
158+ action.server.updateControlProps (props: props);
159+ action.server.sendPageEvent (
160+ eventTarget: "page" ,
161+ eventName: "platformBrightnessChange" ,
162+ eventData: action.brightness.name.toString ());
163+ }
140164 return state.copyWith (displayBrightness: action.brightness);
141165 } else if (action is RegisterWebClientAction ) {
142166 //
@@ -152,7 +176,7 @@ AppState appReducer(AppState state, dynamic action) {
152176 final sessionId = action.payload.session! .id;
153177
154178 // store sessionId in a cookie
155- SessionStore .set ( " sessionId" , sessionId) ;
179+ SessionStore .sessionId = sessionId;
156180
157181 if (state.deepLinkingRoute != "" ) {
158182 debugPrint (
0 commit comments