Skip to content

Commit

Permalink
Web refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maxence-charriere committed May 26, 2018
1 parent 21139d2 commit dbb9d6c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 154 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ examples/test/test


examples/action-event/bin/mac/mac

*.map

*.map

examples/test/bin/test-web/resources/goapp.js.map

examples/test/bin/test-web/resources/goapp.js
8 changes: 6 additions & 2 deletions examples/test/bin/test-web/main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package main

import (
"os"

"github.com/murlokswarm/app"
"github.com/murlokswarm/app/drivers/web"
"github.com/murlokswarm/app/examples/test"
)

func main() {
app.DefaultLogger = app.ConcurrentLogger(app.NewConsole(true))
app.Loggers = []app.Logger{
app.NewLogger(os.Stdout, os.Stderr, true),
}

app.Import(&test.Webview{})
app.Import(&test.Menu{})

app.Run(&web.Driver{
DefaultURL: "/test.Webview",
})
}, app.Logs())
}
121 changes: 0 additions & 121 deletions examples/test/bin/test-web/resources/goapp.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/test/bin/test-web/resources/goapp.js.map

This file was deleted.

45 changes: 15 additions & 30 deletions examples/test/webview.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ func (c *Webview) OnChangeNumber() {

// OnShare is the function that is called when the Share button is clicked.
func (c *Webview) OnShare() {
if err := app.NewShare("Hello world"); err != nil {
app.Log("%s", err)
}
app.NewShare("Hello world")
}

// OnShareURL is the function that is called when the Share URL button is
Expand All @@ -188,79 +186,66 @@ func (c *Webview) OnShareURL() {
if err != nil {
app.Log("%s", err)
}

if err = app.NewShare(u); err != nil {
app.Log("%s", err)
}
app.NewShare(u)
}

// OnDirPanel is the function that is called when the Dir panel button is
// clicked.
func (c *Webview) OnDirPanel() {
if err := app.NewFilePanel(app.FilePanelConfig{
app.NewFilePanel(app.FilePanelConfig{
IgnoreFiles: true,
OnSelect: func(filenames []string) {
app.Log("filenames: %v", filenames)
},
}); err != nil {
app.Log("%s", err)
}
})
}

// OnFilePanel is the function that is called when the File panel button is
// clicked.
func (c *Webview) OnFilePanel() {
if err := app.NewFilePanel(app.FilePanelConfig{
app.NewFilePanel(app.FilePanelConfig{
IgnoreDirectories: true,
ShowHiddenFiles: true,
FileTypes: []string{"public.jpeg", "gif"},
OnSelect: func(filenames []string) {
app.Log("filenames: %v", filenames)
},
}); err != nil {
app.Log("%s", err)
}
})
}

// OnMultipleFilePanel is the function that is called when the Multiple file
// panel button is clicked.
func (c *Webview) OnMultipleFilePanel() {
if err := app.NewFilePanel(app.FilePanelConfig{
app.NewFilePanel(app.FilePanelConfig{
IgnoreDirectories: true,
MultipleSelection: true,
OnSelect: func(filenames []string) {
app.Log("filenames: %v", filenames)
},
}); err != nil {
app.Log("%s", err)
}
})
}

// OnSavePanel is the function that is called when the Save panel button is
// clicked.
func (c *Webview) OnSavePanel() {
if err := app.NewSaveFilePanel(app.SaveFilePanelConfig{
app.NewSaveFilePanel(app.SaveFilePanelConfig{
// FileTypes: []string{"public.jpeg"},
OnSelect: func(filename string) {
app.Log(filename)
},
}); err != nil {
app.Log("%s", err)
}
})
}

// OnNotification is the function that is called when the Notification button is
// clicked.
func (c *Webview) OnNotification() {
if err := app.NewNotification(app.NotificationConfig{
app.NewNotification(app.NotificationConfig{
Title: "hello",
Subtitle: "world",
Text: uuid.New().String(),
ImageName: filepath.Join(app.Resources(), "logo.png"),
Sound: true,
}); err != nil {
app.Log("%s", err)
}
})
}

// OnNotificationWithReply is the function that is called when the Notification
Expand Down Expand Up @@ -292,7 +277,7 @@ func (c *Webview) OnNotificationWithReply() {
func (c *Webview) OnPrevious() {
nav, err := app.NavigatorByComponent(c)
if err != nil {
app.Log("%s", err)
return
}
nav.Previous()
}
Expand All @@ -301,7 +286,7 @@ func (c *Webview) OnPrevious() {
func (c *Webview) OnReload() {
nav, err := app.NavigatorByComponent(c)
if err != nil {
app.Log("%s", err)
return
}
nav.Reload()
}
Expand All @@ -310,7 +295,7 @@ func (c *Webview) OnReload() {
func (c *Webview) OnNext() {
nav, err := app.NavigatorByComponent(c)
if err != nil {
app.Log("%s", err)
return
}
nav.Next()
}
Expand Down

0 comments on commit dbb9d6c

Please sign in to comment.