Skip to content

Commit

Permalink
Back button fix
Browse files Browse the repository at this point in the history
Back button does not work on some android devices, let any device use
the title as a back button
  • Loading branch information
Strosel committed Jun 20, 2023
1 parent 5f8e60c commit 9312130
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
vendorHash = "sha256-2LQCFYyEletx+FswLV1Ui506qG62yHUKGr5vP5Y/b/s=";
doCheck = false;
};

minsdk = "29";
in
{
devShells.default = pkgs.mkShell
Expand All @@ -55,14 +57,14 @@
local V=$(gum input --prompt 'Version? ' --placeholder '7')
gum spin --spinner dot --title "Building..." -- \
gogio -target android -icon assets/meta/icon.png -version $V -minsdk 29 .
gogio -target android -icon assets/meta/icon.png -version $V -minsdk ${minsdk} .
apksigner sign --ks ~/.android/sign.keystore treman.apk
}
stream () {
gum spin --spinner dot --title "Building..." -- \
gogio -target android -icon assets/meta/icon.png -minsdk 29 .
gogio -target android -icon assets/meta/icon.png -minsdk ${minsdk} .
adb uninstall com.github.treman > /dev/null 2>&1
adb install treman.apk
}
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ func loop(w *app.Window, th *material.Theme) error {
switch e := e.(type) {
case system.DestroyEvent:
return e.Err
case key.Event: //NOTE oklart om detta funkar
case key.Event:
if e.Name == key.NameBack {
screen = gameScreen(screen.Rules())
}
//HACK e.Cancel = true
w.Invalidate()
case system.FrameEvent:
gtx := layout.NewContext(&ops, e)
Expand Down
6 changes: 1 addition & 5 deletions viewRules.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"runtime"

"gioui.org/layout"
"gioui.org/unit"
"gioui.org/widget"
Expand Down Expand Up @@ -51,9 +49,7 @@ func (v *viewRules) Layout(gtx Ctx, th *material.Theme) (nextScreen Screen) {
layout.UniformInset(unit.Dp(8)).Layout(gtx, func(gtx Ctx) Dim {
return v.list.Layout(gtx, 4, func(gtx Ctx, i int) Dim {
return layout.UniformInset(unit.Dp(16)).Layout(gtx, func(gtx Ctx) Dim {
if i == 0 && runtime.GOOS == "android" {
return layout.Inset{Top: unit.Dp(16)}.Layout(gtx, material.H6(th, "Regler").Layout)
} else if i == 0 {
if i == 0 {
bttn := material.Button(th, v.cancelClick, "← Regler")
bttn.Color = BLACK
bttn.Background = WHITE
Expand Down

0 comments on commit 9312130

Please sign in to comment.