Skip to content

Commit

Permalink
fix page clickables
Browse files Browse the repository at this point in the history
  • Loading branch information
ugwueze-dev committed Mar 1, 2021
1 parent e01d0bc commit 45f368f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ui/decredmaterial/votebar.go
Expand Up @@ -70,8 +70,8 @@ func (v *VoteBar) SetParams(yesVotes, noVotes, eligibleVotes, requiredPercentage
}

func (v *VoteBar) Layout(gtx C) D {
yesFlex := float32(v.yesVotes / v.totalVotes)
noFlex := float32(v.noVotes / v.totalVotes)
yesFlex := v.yesVotes / v.totalVotes
noFlex := v.noVotes / v.totalVotes

yesRadius := CornerRadius{
SW: 5,
Expand Down
35 changes: 34 additions & 1 deletion ui/proposal_details_page.go
Expand Up @@ -2,6 +2,9 @@ package ui

import (
"encoding/base64"
"fmt"
"os/exec"
"runtime"

"gioui.org/layout"
"gioui.org/unit"
Expand Down Expand Up @@ -29,7 +32,6 @@ type proposalDetails struct {
backButton decredmaterial.IconButton
descriptionCard decredmaterial.Card
proposalItems map[string]proposalItemWidgets
clickables map[string]*widget.Clickable
descriptionList *layout.List
selectedProposal **dcrlibwallet.Proposal
redirectIcon *widget.Image
Expand Down Expand Up @@ -71,6 +73,37 @@ func (pg *proposalDetails) handle(common pageCommon) {
for pg.backButton.Button.Clicked() {
common.ChangePage(PageProposals)
}

for token := range pg.proposalItems {
for location, clickable := range pg.proposalItems[token].clickables {
if clickable.Clicked() {
pg.goToURL(location)
}
}
}

for pg.redirectButton.Clicked() {
proposal := *pg.selectedProposal
pg.goToURL("https://proposals.decred.org/proposals/" + proposal.Token)
}
}

func (pg *proposalDetails) goToURL(url string) {
var err error

switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
default:
err = fmt.Errorf("unsupported platform")
}
if err != nil {
log.Error(err)
}
}

func (pg *proposalDetails) layoutLinkButtons(gtx C) D {
Expand Down

0 comments on commit 45f368f

Please sign in to comment.