Skip to content

Commit

Permalink
Test user interface: UI
Browse files Browse the repository at this point in the history
  • Loading branch information
alg0r1txm committed Jul 11, 2024
1 parent 6bf404b commit cdc6cbe
Show file tree
Hide file tree
Showing 7 changed files with 855 additions and 0 deletions.
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions binary.go

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module github.com/pto-club/95d720b6-6c8a-43f4-8ca9-20e41eccabf1

go 1.22.3

require fyne.io/fyne/v2 v2.4.5

require (
fyne.io/systray v1.10.1-0.20231115130155-104f5ef7839e // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fredbi/uri v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240306074159-ea2d69986ecb // indirect
github.com/go-text/render v0.1.0 // indirect
github.com/go-text/typesetting v0.1.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/tevino/abool v1.2.0 // indirect
github.com/yuin/goldmark v1.5.5 // indirect
golang.org/x/image v0.11.0 // indirect
golang.org/x/mobile v0.0.0-20230531173138-3c911d8e3eda // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
)
666 changes: 666 additions & 0 deletions go.sum

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions gui.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package main

import (
"fmt"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)

type gui struct {
win fyne.Window
fileName widget.Label
}


func (w *gui) Header() *fyne.Container{
open_file := widget.NewToolbarAction(theme.FolderOpenIcon(), w.open_file_onActivate)
toolbar := widget.NewToolbar(open_file)

logo := Logo()

nameApp := widget.NewLabelWithStyle("Catalogul informativ de prețuri la materiale, \n echipamente și utilaje aplicate în achizițiile publice",
fyne.TextAlignCenter,widget.RichTextStyleCodeBlock.TextStyle)

header := container.NewStack(toolbar, logo)
vertical := container.NewVBox(header, nameApp)
return vertical
}

func (w *gui) Center() *fyne.Container{
entry := widget.NewEntry()
entry.SetPlaceHolder("Search string...hhhhh")
entry.Resize(fyne.NewSize(30, 20))
entry.OnSubmitted = func(s string) {} // string entered in textbox

table := widget.NewTableWithHeaders(func() (rows int, cols int) {
return 10, 9
}, func() fyne.CanvasObject {
return widget.NewLabel("test")
}, func(tci widget.TableCellID, co fyne.CanvasObject) {

},
)
table.SetColumnWidth(2, 200)
table.StickyRowCount = 10

cont := container.NewPadded(table)

center := container.NewVBox(entry, cont)
return center
}



func (w *gui) open_file_onActivate() {
fd := dialog.NewFileOpen(
func(file fyne.URIReadCloser, err error) {
if err != nil {
fmt.Printf("Error to open file... %s ", file.URI().Name())
return
}
if file == nil {
return //if press cancel
}
w.win.SetTitle(file.URI().Name())
w.fileName.SetText(file.URI().Name())
}, w.win)
//fd.SetFilter(storage.NewExtensionFileFilter([]string{".db"}))
fd.Show()
}

func Logo() *canvas.Image{
logo := canvas.NewImageFromResource(resourceLogoPng)
logo.FillMode = canvas.ImageFillContain
return logo
}
35 changes: 35 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)

func main() {
application := app.New()
application.Settings().SetTheme(NewSmet4ikTheme())

window := application.NewWindow("Price List smet4ik.CLUB")
window.Resize(fyne.NewSize(900, 500))
window.CenterOnScreen()
window.SetFixedSize(true)

mainWindows := &gui{win: window}

header := mainWindows.Header()
center := mainWindows.Center()

space := widget.NewLabel(" ")

main_container := container.NewBorder(header, nil, space, space, center)



mainWindows.win.SetContent(main_container)
mainWindows.win.Show()
application.Run()

}

27 changes: 27 additions & 0 deletions theme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//go:generate fyne bundle -o binary.go assets
package main

import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)

type smet4ikTheme struct{
fyne.Theme
}

func NewSmet4ikTheme() fyne.Theme{
return &smet4ikTheme{Theme: theme.DefaultTheme()}
}

func (s *smet4ikTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color {
return s.Theme.Color(name, theme.VariantLight) // set always theme-VariantLight
}

func(s *smet4ikTheme) Size(name fyne.ThemeSizeName) float32 {
if name == theme.SizeNameText{
return 10
}
return s.Theme.Size(name)
}

0 comments on commit cdc6cbe

Please sign in to comment.