Skip to content

Commit

Permalink
easter egg
Browse files Browse the repository at this point in the history
  • Loading branch information
dreacot committed Jan 30, 2025
1 parent 404725f commit e68e162
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 51 deletions.
Binary file added ui/assets/decredicons/stakey_deal_with_it.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion ui/cryptomaterial/icon_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type Icons struct {
SimpleSwapIcon, SwapzoneIcon, ShapeShiftIcon, GodexIcon, CoinSwitchIcon, ChangeNowIcon, TrocadorIcon,
LTCBackground, LTCGroupIcon, DCRBackground, LogoDCRSlide, BTCBackground, BTCGroupIcon, CrossPlatformIcon,
IntegratedExchangeIcon, MultiWalletIcon, Dot, TradeExchangeIcon, FilterImgIcon, FilterOffImgIcon, ShareIcon,
CircleBTC, CircleLTC, CircleDCR, TelegramIcon, MatrixIcon, WebsiteIcon, TwitterIcon, OrangeAlert, ImportedAccountIcon *Image
CircleBTC, CircleLTC, CircleDCR, TelegramIcon, MatrixIcon, WebsiteIcon, TwitterIcon, OrangeAlert, ImportedAccountIcon,
StakeyImage *Image

TicketImmatureIcon,
TicketLiveIcon,
Expand Down Expand Up @@ -183,6 +184,7 @@ func (i *Icons) DefaultIcons() *Icons {
i.MatrixIcon = NewImage(decredIcons["ic_matrix"])
i.WebsiteIcon = NewImage(decredIcons["ic_www"])
i.TwitterIcon = NewImage(decredIcons["logo_twitter"])
i.StakeyImage = NewImage(decredIcons["stakey_deal_with_it"])

return i
}
Expand Down
2 changes: 2 additions & 0 deletions ui/modal/info_modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ func (in *InfoModal) SetupWithTemplate(template string) *InfoModal {
customTemplate = totalValueInfo(in.Theme)
case BondStrengthInfoTemplate:
customTemplate = bondStrengthInfo(in.Theme)
case StakeyImageTemplate:
customTemplate = stakeyImage(in.Theme)
}

in.dialogTitle = title
Expand Down
11 changes: 11 additions & 0 deletions ui/modal/info_modal_layouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
SourceModalInfoTemplate = "SourceModalInfo"
TotalValueInfoTemplate = "TotalValueInfo"
BondStrengthInfoTemplate = "BondStrengthInfo"
StakeyImageTemplate = "StakeyImage"
)

func verifyMessageInfo(th *cryptomaterial.Theme) []layout.Widget {
Expand Down Expand Up @@ -129,3 +130,13 @@ func bondStrengthInfo(th *cryptomaterial.Theme) []layout.Widget {
renderers.RenderHTML(text, th).Layout,
}
}

func stakeyImage(th *cryptomaterial.Theme) []layout.Widget {
return []layout.Widget{
func(gtx C) D {
return layout.Center.Layout(gtx, func(gtx C) D {
return th.Icons.StakeyImage.LayoutSize(gtx, values.MarginPadding200)
})
},
}
}
107 changes: 57 additions & 50 deletions ui/page/settings/about_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package settings

import (
"gioui.org/layout"

Check failure on line 4 in ui/page/settings/about_page.go

View workflow job for this annotation

GitHub Actions / Build

File is not `goimports`-ed (goimports)
"time"

"github.com/crypto-power/cryptopower/app"
"github.com/crypto-power/cryptopower/ui/cryptomaterial"
"github.com/crypto-power/cryptopower/ui/load"
"github.com/crypto-power/cryptopower/ui/modal"
"github.com/crypto-power/cryptopower/ui/page/components"
"github.com/crypto-power/cryptopower/ui/values"
)
Expand All @@ -14,15 +16,11 @@ const AboutPageID = "About"

type AboutPage struct {
*load.Load
// GenericPageModal defines methods such as ID() and OnAttachedToNavigator()
// that helps this Page satisfy the app.Page interface. It also defines
// helper methods for accessing the PageNavigator that displayed this page
// and the root WindowNavigator.
*app.GenericPageModal

card cryptomaterial.Card
container *layout.List

card cryptomaterial.Card
container *layout.List
versionRow *cryptomaterial.Clickable
version cryptomaterial.Label
versionValue cryptomaterial.Label
buildDate cryptomaterial.Label
Expand All @@ -33,6 +31,9 @@ type AboutPage struct {
licenseRow *cryptomaterial.Clickable
backButton cryptomaterial.IconButton
shadowBox *cryptomaterial.Shadow

versionTapCount int // Tap counter
lastTapTime time.Time // Track last tap time
}

func NewAboutPage(l *load.Load) *AboutPage {
Expand All @@ -41,6 +42,7 @@ func NewAboutPage(l *load.Load) *AboutPage {
GenericPageModal: app.NewGenericPageModal(AboutPageID),
card: l.Theme.Card(),
container: &layout.List{Axis: layout.Vertical},
versionRow: l.Theme.NewClickable(true),
version: l.Theme.Body1(values.String(values.StrVersion)),
versionValue: l.Theme.Body1(l.AppInfo.Version()),
buildDate: l.Theme.Body1(values.String(values.StrBuildDate)),
Expand All @@ -49,11 +51,16 @@ func NewAboutPage(l *load.Load) *AboutPage {
license: l.Theme.Body1(values.String(values.StrLicense)),
licenseRow: l.Theme.NewClickable(true),
shadowBox: l.Theme.Shadow(),
versionTapCount: 0,
lastTapTime: time.Time{},
}

pg.licenseRow.Radius = cryptomaterial.BottomRadius(14)

pg.backButton = components.GetBackButton(l)

pg.versionRow.Hoverable = false
pg.versionRow.Radius = cryptomaterial.TopRadius(14)

col := pg.Theme.Color.GrayText2
pg.versionValue.Color = col
pg.buildDateValue.Color = col
Expand All @@ -65,16 +72,8 @@ func NewAboutPage(l *load.Load) *AboutPage {
return pg
}

// OnNavigatedTo is called when the page is about to be displayed and
// may be used to initialize page features that are only relevant when
// the page is displayed.
// Part of the load.Page interface.
func (pg *AboutPage) OnNavigatedTo() {
}
func (pg *AboutPage) OnNavigatedTo() {}

// Layout draws the page UI components into the provided C
// to be eventually drawn on screen.
// Part of the load.Page interface.
func (pg *AboutPage) Layout(gtx C) D {
return pg.layoutDesktop(gtx)
}
Expand Down Expand Up @@ -134,8 +133,10 @@ func (pg *AboutPage) layoutRows(gtx C) D {
}
w := []func(gtx C) D{
func(gtx C) D {
return components.Container{Padding: in}.Layout(gtx, func(gtx C) D {
return components.EndToEndRow(gtx, pg.version.Layout, pg.versionValue.Layout)
return pg.versionRow.Layout(gtx, func(gtx C) D {
return components.Container{Padding: in}.Layout(gtx, func(gtx C) D {
return components.EndToEndRow(gtx, pg.version.Layout, pg.versionValue.Layout)
})
})
},
func(gtx C) D {
Expand All @@ -148,26 +149,19 @@ func (pg *AboutPage) layoutRows(gtx C) D {
return components.EndToEndRow(gtx, pg.network.Layout, pg.networkValue.Layout)
})
},

func(gtx C) D {
licenseRowLayout := func(gtx C) D {
return pg.licenseRow.Layout(gtx, func(gtx C) D {
return layout.Flex{}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return in.Layout(gtx, pg.license.Layout)
}),
layout.Flexed(1, func(gtx C) D {
return layout.E.Layout(gtx, func(gtx C) D {
return in.Layout(gtx, pg.Theme.NewIcon(pg.Theme.Icons.ChevronRight).Layout24dp)
})
}),
)
})
}
if pg.licenseRow.IsHovered() {
return pg.shadowBox.Layout(gtx, licenseRowLayout)
}
return licenseRowLayout(gtx)
return pg.licenseRow.Layout(gtx, func(gtx C) D {
return layout.Flex{}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return in.Layout(gtx, pg.license.Layout)
}),
layout.Flexed(1, func(gtx C) D {
return layout.E.Layout(gtx, func(gtx C) D {
return in.Layout(gtx, pg.Theme.NewIcon(pg.Theme.Icons.ChevronRight).Layout24dp)
})
}),
)
})
},
}

Expand All @@ -188,11 +182,6 @@ func (pg *AboutPage) layoutRows(gtx C) D {
})
}

// HandleUserInteractions is called just before Layout() to determine
// if any user interaction recently occurred on the page and may be
// used to update the page's UI components shortly before they are
// displayed.
// Part of the load.Page interface.
func (pg *AboutPage) HandleUserInteractions(gtx C) {
if pg.licenseRow.Clicked(gtx) {
pg.ParentNavigator().Display(NewLicensePage(pg.Load))
Expand All @@ -201,13 +190,31 @@ func (pg *AboutPage) HandleUserInteractions(gtx C) {
if pg.backButton.Button.Clicked(gtx) {
pg.ParentNavigator().CloseCurrentPage()
}

if pg.versionRow.Clicked(gtx) {
now := time.Now()
if now.Sub(pg.lastTapTime) > 5*time.Second {
pg.versionTapCount = 0
}

pg.versionTapCount++
pg.lastTapTime = now

if pg.versionTapCount >= 5 {
pg.versionTapCount = 0
pg.showSecretModal()
}
}
}

func (pg *AboutPage) showSecretModal() {
secretModal := modal.NewCustomModal(pg.Load).
SetCancelable(true).
SetupWithTemplate(modal.StakeyImageTemplate).
SetContentAlignment(layout.W, layout.Center, layout.Center).
SetPositiveButtonText("") // No positive button

pg.ParentWindow().ShowModal(secretModal)
}

// OnNavigatedFrom is called when the page is about to be removed from
// the displayed window. This method should ideally be used to disable
// features that are irrelevant when the page is NOT displayed.
// NOTE: The page may be re-displayed on the app's window, in which case
// OnNavigatedTo() will be called again. This method should not destroy UI
// components unless they'll be recreated in the OnNavigatedTo() method.
// Part of the load.Page interface.
func (pg *AboutPage) OnNavigatedFrom() {}

0 comments on commit e68e162

Please sign in to comment.