File tree 4 files changed +63
-12
lines changed
packages/explo_ide_view/lib
4 files changed +63
-12
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,8 @@ modules.xml
337
337
.LSOverride
338
338
339
339
# Icon must end with two \r
340
- Icon
340
+ Icon
341
+
341
342
342
343
# Thumbnails
343
344
._ *
@@ -536,3 +537,4 @@ $RECYCLE.BIN/
536
537
537
538
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
538
539
540
+ * .vsix
Original file line number Diff line number Diff line change 1
1
import {
2
+ ColorThemeKind ,
2
3
commands ,
3
4
Disposable ,
4
5
ExtensionContext ,
@@ -92,6 +93,9 @@ export class ExploViewCommands implements Disposable {
92
93
panel . webview . html = exploWebviewContent ( {
93
94
baseUri : baseUri . toString ( ) ,
94
95
vmServiceUri : session . vmServiceUri ! ,
96
+ themeMode : vscodeColorThemeKindToExploThemeMode (
97
+ window . activeColorTheme . kind
98
+ ) ,
95
99
} )
96
100
97
101
this . openViewPanels . set ( session , panel )
@@ -112,12 +116,29 @@ export class ExploViewCommands implements Disposable {
112
116
}
113
117
}
114
118
119
+ enum ExploThemeMode {
120
+ light = 'light' ,
121
+ dark = 'dark' ,
122
+ }
123
+
124
+ function vscodeColorThemeKindToExploThemeMode ( kind : ColorThemeKind ) {
125
+ switch ( kind ) {
126
+ case ColorThemeKind . HighContrast :
127
+ case ColorThemeKind . Dark :
128
+ return ExploThemeMode . dark
129
+ case ColorThemeKind . Light :
130
+ return ExploThemeMode . light
131
+ }
132
+ }
133
+
115
134
function exploWebviewContent ( {
116
135
baseUri,
117
136
vmServiceUri,
137
+ themeMode,
118
138
} : {
119
139
baseUri : string
120
140
vmServiceUri : string
141
+ themeMode : 'light' | 'dark'
121
142
} ) : string {
122
143
return `
123
144
<!DOCTYPE html>
@@ -132,7 +153,8 @@ function exploWebviewContent({
132
153
// Prepare browser environment for the view.
133
154
window.explo = {
134
155
config: {
135
- vmServiceUri: '${ vmServiceUri } '
156
+ vmServiceUri: '${ vmServiceUri } ',
157
+ themeMode: '${ themeMode } '
136
158
}
137
159
}
138
160
Original file line number Diff line number Diff line change
1
+ /// The config properties in this library have to be set in the browser
2
+ /// environment, before the Flutter app is loaded.
3
+ ///
4
+ /// ```js
5
+ /// window.explo = {
6
+ /// config: {
7
+ /// vmServiceUri: ...,
8
+ /// themeMode: ...,
9
+ /// }
10
+ /// }
11
+ /// ```
1
12
@JS ('explo.config' )
2
13
library config;
3
14
15
+ import 'package:flutter/material.dart' ;
4
16
import 'package:js/js.dart' ;
5
17
6
18
/// The VM Service URI of the target.
7
- ///
8
- /// This has to be set in the browser environment, before the Flutter app is
9
- /// loaded.
10
- ///
11
- /// ```js
12
- /// window.explo = { config: { vmServiceUri: ... } }
13
- /// ```
14
- @JS ()
15
- external String get vmServiceUri;
19
+ Uri get vmServiceUri => Uri .parse (_vmServiceUri);
20
+
21
+ @JS ('vmServiceUri' )
22
+ external String get _vmServiceUri;
23
+
24
+ /// The theme mode to use for the view.
25
+ ThemeMode get themeMode => parseThemeMode (_themeMode);
26
+
27
+ @JS ('themeMode' )
28
+ external String get _themeMode;
29
+
30
+ ThemeMode parseThemeMode (String value) {
31
+ switch (value) {
32
+ case 'dark' :
33
+ return ThemeMode .dark;
34
+ case 'light' :
35
+ return ThemeMode .light;
36
+ default :
37
+ throw ArgumentError .value (value, 'value' , 'Unknown theme mode' );
38
+ }
39
+ }
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ class MyApp extends StatelessWidget {
19
19
return MaterialApp (
20
20
theme: ThemeData .from (colorScheme: const ColorScheme .light ()),
21
21
darkTheme: ThemeData .from (colorScheme: const ColorScheme .dark ()),
22
- home: ExploView (vmServiceUri: Uri .parse (vmServiceUri)),
22
+ home: ExploView (
23
+ vmServiceUri: vmServiceUri,
24
+ themeMode: themeMode,
25
+ ),
23
26
);
24
27
}
25
28
}
You can’t perform that action at this time.
0 commit comments