Skip to content

Commit

Permalink
Merge pull request #9 from dReam-dApps/duels
Browse files Browse the repository at this point in the history
0.10.1
  • Loading branch information
SixofClubsss authored Aug 30, 2023
2 parents 741feeb + 5c181b0 commit 5b29b57
Show file tree
Hide file tree
Showing 21 changed files with 817 additions and 246 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Interact with a variety of different products and services on [Dero's](https://d
### Project
dReams is a open source platform application that houses multiple *desktop* dApps and utilities built on Dero. dReams has two facets to its use.

![goMod](https://img.shields.io/github/go-mod/go-version/dReam-dApps/dReams.svg)![goReport](https://goreportcard.com/badge/github.com/dReam-dApps/dReams)[![goDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/dReam-dApps/dReams)

As a application
> With a wide array of features from games to blockchain services, dReams is a point of entry into the privacy preserving world of Dero.
Expand All @@ -26,6 +28,8 @@ As a repository
Download the latest [release](https://github.com/dReam-dApps/dReams/releases) or [build from source](#build) to use dReams.

![windowsOS](https://raw.githubusercontent.com/SixofClubsss/dreamdappsite/main/assets/os-windows-green.svg)![macOS](https://raw.githubusercontent.com/SixofClubsss/dreamdappsite/main/assets/os-macOS-green.svg)![linuxOS](https://raw.githubusercontent.com/SixofClubsss/dreamdappsite/main/assets/os-linux-green.svg)

dReams [Template](https://github.com/dReam-dApps/Template) can be used to help create new Dero dApps.

### dApps
Expand Down Expand Up @@ -150,28 +154,35 @@ The menu package contains the base components used for Gnomon indexing. `StartGn
package main
import (
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/civilware/Gnomon/structures"
"github.com/dReam-dApps/dReams/menu"
"github.com/dReam-dApps/dReams/rpc"
"github.com/sirupsen/logrus"
)
// dReams menu StartGnomon() example
// Name my app
const app_tag = "My_app"
// Log output
var logger = structures.Logger.WithFields(logrus.Fields{})
func main() {
// Initialize Gnomon fast sync
menu.Gnomes.Fast = true
// Initialize rpc address to rpc.Daemon var
rpc.Daemon.Rpc = "127.0.0.1:10102"
// Initialize logger to Stdout
menu.InitLogrusLog(logrus.InfoLevel)
rpc.Ping()
// Check for daemon connection, if daemon is not connected we won't start Gnomon
if rpc.Daemon.Connect {
Expand All @@ -191,7 +202,7 @@ func main() {
// Gnomon will continue to run if daemon is connected
for !exit && rpc.Daemon.Connect {
contracts := menu.Gnomes.GetAllOwnersAndSCIDs()
log.Printf("[%s] Index contains %d contracts\n", app_tag, len(contracts))
logger.Printf("[%s] Index contains %d contracts\n", app_tag, len(contracts))
time.Sleep(3 * time.Second)
rpc.Ping()
}
Expand All @@ -200,7 +211,7 @@ func main() {
menu.Gnomes.Stop(app_tag)
}
log.Printf("[%s] Done\n", app_tag)
logger.Printf("[%s] Done\n", app_tag)
}
```
### dwidget
Expand All @@ -215,6 +226,7 @@ import (
"github.com/dReam-dApps/dReams/dwidget"
"github.com/dReam-dApps/dReams/menu"
"github.com/dReam-dApps/dReams/rpc"
"github.com/sirupsen/logrus"
)
// dReams dwidget NewVerticalEntries() example
Expand All @@ -226,6 +238,9 @@ func main() {
// Initialize Gnomon fast sync
menu.Gnomes.Fast = true
// Initialize logger to Stdout
menu.InitLogrusLog(logrus.InfoLevel)
// Initialize fyne app
a := app.New()
Expand Down Expand Up @@ -274,6 +289,7 @@ import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"github.com/dReam-dApps/dReams/bundle"
"github.com/dReam-dApps/dReams/dwidget"
)
// Name my app
Expand All @@ -295,7 +311,7 @@ func main() {
// Initialize fyne container and add some various widgets for viewing purposes
cont := container.NewVBox()
cont.Add(container.NewAdaptiveGrid(3, widget.NewLabel("Label"), widget.NewEntry(), widget.NewButton("Button", nil)))
cont.Add(container.NewAdaptiveGrid(3, dwidget.NewCenterLabel("Label"), widget.NewEntry(), widget.NewButton("Button", nil)))
cont.Add(container.NewAdaptiveGrid(3, widget.NewLabel("Label"), widget.NewCheck("Check", nil), widget.NewButton("Button", nil)))
cont.Add(widget.NewPasswordEntry())
cont.Add(widget.NewSlider(0, 100))
Expand Down
10 changes: 10 additions & 0 deletions bundle/bundled.go

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions bundle/icons.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package bundle

import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
)

// Left arrow icon *canvas.Image
func LeftArrow(size fyne.Size) fyne.CanvasObject {
leftArrow := canvas.NewImageFromResource(ResourceLeftArrowPng)
leftArrow.SetMinSize(size)

return container.NewMax(leftArrow)
}

// Right arrow icon *canvas.Image
func RightArrow(size fyne.Size) fyne.CanvasObject {
rightArrow := canvas.NewImageFromResource(ResourceRightArrowPng)
rightArrow.SetMinSize(size)

return container.NewMax(rightArrow)
}
74 changes: 40 additions & 34 deletions cmd/NFA/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"syscall"
"time"

"github.com/civilware/Gnomon/structures"
dreams "github.com/dReam-dApps/dReams"
"github.com/dReam-dApps/dReams/bundle"
"github.com/dReam-dApps/dReams/dwidget"
"github.com/dReam-dApps/dReams/menu"
"github.com/dReam-dApps/dReams/rpc"
"github.com/sirupsen/logrus"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
Expand All @@ -27,33 +29,57 @@ const app_tag = "NFA Market"
func main() {
n := runtime.NumCPU()
runtime.GOMAXPROCS(n)
menu.InitLogrusLog(runtime.GOOS == "windows")
menu.InitLogrusLog(logrus.InfoLevel)
logger := structures.Logger.WithFields(logrus.Fields{})
config := menu.ReadDreamsConfig(app_tag)

a := app.New()
// Initialize Fyne app and window
a := app.NewWithID(fmt.Sprintf("%s Desktop Client", app_tag))
a.Settings().SetTheme(bundle.DeroTheme(config.Skin))
w := a.NewWindow(app_tag)
w.Resize(fyne.NewSize(1200, 800))
w.Resize(fyne.NewSize(1400, 800))
w.SetIcon(bundle.ResourceMarketIconPng)
w.SetMaster()

// Initialize closing channels and func
quit := make(chan struct{})
done := make(chan struct{})
w.SetCloseIntercept(func() {
menu.WriteDreamsConfig(
dreams.DreamSave{
Skin: config.Skin,
Daemon: []string{rpc.Daemon.Rpc},
DBtype: menu.Gnomes.DBType,
})
closeFunc := func() {
save := dreams.SaveData{
Skin: config.Skin,
DBtype: menu.Gnomes.DBType,
}

if rpc.Daemon.Rpc == "" {
save.Daemon = config.Daemon
} else {
save.Daemon = []string{rpc.Daemon.Rpc}
}

menu.WriteDreamsConfig(save)
menu.CloseAppSignal(true)
menu.Gnomes.Stop(app_tag)
quit <- struct{}{}
if rpc.Wallet.File != nil {
rpc.Wallet.File.Close_Encrypted_Wallet()
}
w.Close()
})
}
w.SetCloseIntercept(closeFunc)

// Handle ctrl-c close
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println()
closeFunc()
}()

// Initialize vars
menu.Gnomes.Fast = true

// Create dwidget connection box with controls
connect_box := dwidget.NewHorizontalEntries(app_tag, 1)
connect_box.Button.OnTapped = func() {
rpc.GetAddress(app_tag)
Expand All @@ -74,40 +100,20 @@ func main() {
connect_box.AddDaemonOptions(config.Daemon)
connect_box.Container.Objects[0].(*fyne.Container).Add(menu.StartIndicators())

// Layout tabs
tabs := container.NewAppTabs(
container.NewTabItem("Market", menu.PlaceMarket()),
container.NewTabItem("Assets", menu.PlaceAssets(app_tag, nil, bundle.ResourceMarketIconPng, w)),
container.NewTabItem("Mint", menu.PlaceNFAMint(app_tag, w)))

tabs.SetTabLocation(container.TabLocationBottom)

max := container.NewMax(tabs, container.NewVBox(layout.NewSpacer(), connect_box.Container))

c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println()
menu.WriteDreamsConfig(
dreams.DreamSave{
Skin: config.Skin,
Daemon: []string{rpc.Daemon.Rpc},
DBtype: menu.Gnomes.DBType,
})
menu.Gnomes.Stop(app_tag)
rpc.Wallet.Connected(false)
quit <- struct{}{}
if rpc.Wallet.File != nil {
rpc.Wallet.File.Close_Encrypted_Wallet()
}
w.Close()
}()

go menu.RunNFAMarket(app_tag, quit, done, connect_box)
go func() {
time.Sleep(450 * time.Millisecond)
w.SetContent(max)
w.SetContent(container.NewMax(tabs, container.NewVBox(layout.NewSpacer(), connect_box.Container)))
}()
w.ShowAndRun()
<-done
logger.Printf("[%s] Closed\n", app_tag)
}
Loading

0 comments on commit 5b29b57

Please sign in to comment.