(promptText string)
| 13170 | } |
| 13171 | |
| 13172 | func layoutContractBuilder(promptText string) fyne.CanvasObject { |
| 13173 | session.Domain = "app.sc.builder" |
| 13174 | |
| 13175 | frame := &iframe{} |
| 13176 | |
| 13177 | rectBox := canvas.NewRectangle(color.Transparent) |
| 13178 | rectBox.SetMinSize(fyne.NewSize(ui.MaxWidth*0.9, ui.MaxHeight*0.35)) |
| 13179 | |
| 13180 | rectWidth100 := canvas.NewRectangle(color.Transparent) |
| 13181 | rectWidth100.SetMinSize(fyne.NewSize(ui.Width*0.99, 10)) |
| 13182 | |
| 13183 | rectWidth90 := canvas.NewRectangle(color.Transparent) |
| 13184 | rectWidth90.SetMinSize(fyne.NewSize(ui.Width*0.9, 10)) |
| 13185 | |
| 13186 | rectSpacer := canvas.NewRectangle(color.Transparent) |
| 13187 | rectSpacer.SetMinSize(fyne.NewSize(6, 5)) |
| 13188 | |
| 13189 | heading := canvas.NewText("C O N T R A C T B U I L D E R", colors.Gray) |
| 13190 | heading.TextSize = 16 |
| 13191 | heading.Alignment = fyne.TextAlignCenter |
| 13192 | heading.TextStyle = fyne.TextStyle{Bold: true} |
| 13193 | |
| 13194 | errorText := canvas.NewText(promptText, colors.Red) |
| 13195 | errorText.TextSize = 12 |
| 13196 | errorText.Alignment = fyne.TextAlignCenter |
| 13197 | |
| 13198 | // Open .bas SC from file browser |
| 13199 | dialogBrowse := dialog.NewFileOpen(func(uc fyne.URIReadCloser, err error) { |
| 13200 | errorText.Text = "" |
| 13201 | if uc != nil { |
| 13202 | filename := uc.URI().Name() |
| 13203 | if uc.URI().MimeType() != "text/plain" { |
| 13204 | logger.Errorf("[Engram] Cannot open file %s in contract builder\n", filename) |
| 13205 | errorText.Text = "cannot open file" |
| 13206 | errorText.Color = colors.Red |
| 13207 | errorText.Refresh() |
| 13208 | return |
| 13209 | } |
| 13210 | |
| 13211 | if filepath.Ext(filename) != ".bas" { |
| 13212 | errorText.Text = "requires a .bas file" |
| 13213 | errorText.Color = colors.Red |
| 13214 | errorText.Refresh() |
| 13215 | return |
| 13216 | } |
| 13217 | |
| 13218 | filedata, err := readFromURI(uc) |
| 13219 | if err != nil { |
| 13220 | logger.Errorf("[Engram] Cannot read URI file data for %s: %s\n", filename, err) |
| 13221 | errorText.Text = "cannot read file data" |
| 13222 | errorText.Color = colors.Red |
| 13223 | errorText.Refresh() |
| 13224 | return |
| 13225 | } |
| 13226 | |
| 13227 | if !isASCII(string(filedata)) { |
| 13228 | errorText.Text = "invalid file data" |
| 13229 | errorText.Color = colors.Red |
no test coverage detected