diff --git a/frontend/src/dialogs/input.svelte b/frontend/src/dialogs/input.svelte new file mode 100644 index 0000000..b6f75d2 --- /dev/null +++ b/frontend/src/dialogs/input.svelte @@ -0,0 +1,38 @@ + + + + {#if description} +

{description}

+ {/if} + +
+ +
+ + + + + +
diff --git a/frontend/src/lib/dialogs.js b/frontend/src/lib/dialogs.js index 2d434a4..1ddf45d 100644 --- a/frontend/src/lib/dialogs.js +++ b/frontend/src/lib/dialogs.js @@ -1,3 +1,5 @@ +import InputDialog from '../dialogs/input.svelte'; + function newDialog(dialogComponent, data = {}) { const outlet = document.createElement('div'); outlet.className = 'dialogoutlet'; @@ -15,6 +17,17 @@ function newDialog(dialogComponent, data = {}) { return instance; } -const dialogs = { new: newDialog }; +function enterText(title = '', description = '', value = '') { + const instance = newDialog(InputDialog, { title, description, value }); + + return new Promise(resolve => { + instance.$on('submit', event => { + instance.$close(); + resolve(event.detail.value); + }); + }); +} + +const dialogs = { new: newDialog, enterText }; export default dialogs; diff --git a/frontend/wailsjs/go/ui/UI.d.ts b/frontend/wailsjs/go/ui/UI.d.ts index 13da8e8..9a21c46 100755 --- a/frontend/wailsjs/go/ui/UI.d.ts +++ b/frontend/wailsjs/go/ui/UI.d.ts @@ -4,8 +4,6 @@ import {context} from '../models'; export function Beep():Promise; -export function EnterText(arg1:string,arg2:string,arg3:string):Promise; - export function OpenDirectory(arg1:string):Promise; export function Reveal(arg1:string):Promise; diff --git a/frontend/wailsjs/go/ui/UI.js b/frontend/wailsjs/go/ui/UI.js index ce98890..9c4e414 100755 --- a/frontend/wailsjs/go/ui/UI.js +++ b/frontend/wailsjs/go/ui/UI.js @@ -6,10 +6,6 @@ export function Beep() { return window['go']['ui']['UI']['Beep'](); } -export function EnterText(arg1, arg2, arg3) { - return window['go']['ui']['UI']['EnterText'](arg1, arg2, arg3); -} - export function OpenDirectory(arg1) { return window['go']['ui']['UI']['OpenDirectory'](arg1); } diff --git a/go.mod b/go.mod index 0f6825e..8c47c42 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/garraflavatra/rolens go 1.18 -require github.com/wailsapp/wails/v2 v2.5.1 +require github.com/wailsapp/wails/v2 v2.3.1 require ( github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 @@ -13,6 +13,7 @@ require ( require ( github.com/akavel/rsrc v0.10.2 // indirect github.com/dchest/jsmin v0.0.0-20220218165748-59f39799265f // indirect + github.com/imdario/mergo v0.3.12 // indirect github.com/josephspurrier/goversioninfo v1.4.0 // indirect github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 // indirect golang.org/x/image v0.7.0 // indirect diff --git a/go.sum b/go.sum index c9c76fb..7fee319 100644 --- a/go.sum +++ b/go.sum @@ -21,6 +21,8 @@ github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8= @@ -76,7 +78,7 @@ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG0 github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8= github.com/tkrajina/go-reflector v0.5.5 h1:gwoQFNye30Kk7NrExj8zm3zFtrGPqOkzFMLuQZg1DtQ= github.com/tkrajina/go-reflector v0.5.5/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -85,8 +87,8 @@ github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52 github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= -github.com/wailsapp/wails/v2 v2.5.1 h1:mfG+2kWqQXYOwdgI43HEILjOZDXbk5woPYI3jP2b+js= -github.com/wailsapp/wails/v2 v2.5.1/go.mod h1:jbOZbcr/zm79PxXxAjP8UoVlDd9wLW3uDs+isIthDfs= +github.com/wailsapp/wails/v2 v2.3.1 h1:ZJz+pyIBKyASkgO8JO31NuHO1gTTHmvwiHYHwei1CqM= +github.com/wailsapp/wails/v2 v2.3.1/go.mod h1:zlNLI0E2c2qA6miiuAHtp0Bac8FaGH0tlhA19OssR/8= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= @@ -159,6 +161,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/internal/ui/dialogs.go b/internal/ui/dialogs.go index 1845abb..b40c27c 100644 --- a/internal/ui/dialogs.go +++ b/internal/ui/dialogs.go @@ -15,16 +15,3 @@ func (u *UI) OpenDirectory(title string) string { return dir } - -func (u *UI) EnterText(title, info, defaultEntry string) string { - input, err := zenity.Entry(info, zenity.Title(title), zenity.EntryText(defaultEntry), zenity.Modal()) - - if err == zenity.ErrCanceled { - return "" - } else if err != nil { - zenity.Error(err.Error(), zenity.Title("Encountered an error!"), zenity.ErrorIcon) - return "" - } else { - return input - } -}