@@ -23,9 +23,10 @@ import { ErrorIcon, useToast, WarningIcon } from "react-toast-plus";
2323import SwiftMenu from "../components/SwiftMenu" ;
2424import { restartServer } from "../utilities/lsp-client" ;
2525import BottomBar from "../components/Tiles/BottomBar" ;
26- import { open as openFileDialog } from "@tauri-apps/plugin-dialog" ;
26+ import { open as openFileDialog , save } from "@tauri-apps/plugin-dialog" ;
2727import { IStandaloneCodeEditor } from "@codingame/monaco-vscode-api/vscode/vs/editor/standalone/browser/standaloneCodeEditor" ;
2828import { DARWIN_SDK_VERSION } from "../utilities/constants" ;
29+ import { writeFile } from "@tauri-apps/plugin-fs" ;
2930
3031export interface IDEProps { }
3132
@@ -54,6 +55,8 @@ export default () => {
5455 initialized,
5556 ready,
5657 darwinSDKVersion,
58+ screenshot,
59+ setScreenshot,
5760 } = useIDE ( ) ;
5861 const [ sourcekitStartup , setSourcekitStartup ] = useStore < boolean | null > (
5962 "sourcekit/startup" ,
@@ -206,7 +209,7 @@ export default () => {
206209 < Splitter
207210 gutterTheme = { theme === "dark" ? GutterTheme . Dark : GutterTheme . Light }
208211 direction = { SplitDirection . Horizontal }
209- initialSizes = { [ 20 , 80 ] }
212+ initialSizes = { screenshot ? [ 20 , 50 , 30 ] : [ 20 , 80 ] }
210213 >
211214 < Tile className = "file-explorer-tile" >
212215 < FileExplorer openFolder = { path } setOpenFile = { openNewFile } />
@@ -228,6 +231,40 @@ export default () => {
228231 />
229232 < BottomBar />
230233 </ Splitter >
234+ { screenshot && (
235+ < div className = "screenshot-tile" >
236+ < div >
237+ < Typography level = "h3" > Screenshot</ Typography >
238+ < Button
239+ variant = "outlined"
240+ onClick = { async ( ) => {
241+ const blob = await ( await fetch ( screenshot ) ) . blob ( ) ;
242+ const arrayBuffer = await blob . arrayBuffer ( ) ;
243+ const uint8Array = new Uint8Array ( arrayBuffer ) ;
244+ const savePath = await save ( {
245+ title : "Save Screenshot" ,
246+ defaultPath : "screenshot.png" ,
247+ filters : [
248+ { name : "PNG Image" , extensions : [ "png" ] } ,
249+ { name : "All Files" , extensions : [ "*" ] } ,
250+ ] ,
251+ } ) ;
252+ if ( ! savePath ) return ;
253+ await writeFile ( savePath , uint8Array ) ;
254+ addToast . success ( "Saved screenshot to " + savePath ) ;
255+ } }
256+ >
257+ Save
258+ </ Button >
259+ < Button variant = "outlined" onClick = { ( ) => setScreenshot ( null ) } >
260+ Close
261+ </ Button >
262+ </ div >
263+ < div className = "screenshot-img-container" >
264+ < img src = { screenshot } alt = "screenshot" />
265+ </ div >
266+ </ div >
267+ ) }
231268 </ Splitter >
232269 { initialized &&
233270 selectedToolchain !== null &&
0 commit comments