~f4814n/frost

fb80ddb68f69b6067000991442aa9137576e0375 — Fabian Geiselhart 4 months ago 806c9ee
bump gio version
M build.sh => build.sh +9 -4
@@ 1,8 1,8 @@
#!/usr/bin/env bash

build_android() {
	go run gioui.org/cmd/gogio -target android -appid de.f4814n.frost ./cmd/frost
	apksigner sign --ks $1 frost.apk
	go run gioui.org/cmd/gogio -target android -appid de.f4814n.frost $GOGIO_FLAGS ./cmd/frost
	apksigner sign --ks $KEYSTORE frost.apk
}

build_linux() {


@@ 10,13 10,13 @@ build_linux() {
}

build_wasm() {
	go run gioui.org/cmd/gogio -target js ./cmd/frost
	go run gioui.org/cmd/gogio -target js $GOGIO_FLAGS -o frost.wasm ./cmd/frost
}

case "$1" in
"android")
	set -x
	build_android $2
	build_android
	;;
"linux")
	set -x 


@@ 26,4 26,9 @@ case "$1" in
	set -x
	build_wasm
	;;
"all")
	set -x
	build_wasm
	build_linux
	build_android
esac

M cmd/frost/merge_view.go => cmd/frost/merge_view.go +1 -1
@@ 168,7 168,7 @@ func (v NoView) Layout(gtx Gtx) Dims {
	return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
		layout.Rigid(func(gtx Gtx) Dims {
			return layout.Stack{Alignment: layout.SW}.Layout(gtx,
				layout.Expanded(fwidget.Fill{theme.Color.Primary}.Layout),
				layout.Expanded(fwidget.Fill{theme.Palette.ContrastBg}.Layout),
				layout.Stacked(func(gtx Gtx) Dims {
					return Dims{Size: image.Point{X: gtx.Constraints.Max.X, Y: gtx.Px(unit.Dp(48))}}
				}),

M flake.nix => flake.nix +13 -4
@@ 14,10 14,15 @@
    let
      devShell = with import nixpkgs { system = "x86_64-linux"; config = { android_sdk.accept_license = true; }; }; {
        devShell."x86_64-linux" = let
            sdk = (androidenv.composeAndroidPackages{ platformVersions = [ "28" ]; abiVersions = [ "arm64" ]; includeNDK = true; includeEmulator = true; }).androidsdk;
          android = androidenv.composeAndroidPackages{
            platformVersions = [ "28" ];
            abiVersions = [ "arm64" ];
            includeNDK = true;
            includeEmulator = true;
          };
        in mkShell {
          buildInputs = [
            sdk
            android.androidsdk
            openjdk
            nixfmt
            go


@@ 30,11 35,15 @@
            wayland
            libxkbcommon
            libGL
            graphviz
            olm
            xorg.libXcursor
            xorg.libXfixes
          ];
          shellHook = ''
            export GOPATH=~/.cache/gopath
            export PATH=$(go env GOPATH)/bin:$PATH
            export ANDROID_SDK_ROOT=${sdk}/libexec/android-sdk
            export PATH=$(go env GOPATH)/bin:${android.androidsdk}/libexec/android-sdk/build-tools/28.0.3:$PATH
            export ANDROID_SDK_ROOT=${android.androidsdk}/libexec/android-sdk
          '';
        };
      };

M go.mod => go.mod +1 -2
@@ 3,10 3,9 @@ module git.sr.ht/~f4814n/frost
go 1.14

require (
	gioui.org v0.0.0-20201018162216-7a4b48f67b54
	gioui.org v0.0.0-20201224113856-0416fffc096b
	gioui.org/cmd v0.0.0-20201020094634-d5bdf0756a5a
	git.sr.ht/~f4814n/matrix v0.0.0-20201218143803-770e10bd6252
	github.com/sirupsen/logrus v1.7.0
	go.uber.org/zap v1.16.0
	golang.org/x/exp v0.0.0-20201008143054-e3b2a7f2fdc7
	golang.org/x/image v0.0.0-20200618115811-c13761719519

M go.sum => go.sum +2 -9
@@ 1,11 1,9 @@
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20200726090130-3b95e2918359/go.mod h1:jiUwifN9cRl/zmco43aAqh0aV+s9GbhG13KcD+gEpkU=
gioui.org v0.0.0-20201018162216-7a4b48f67b54 h1:mM+tSH6C2GBkaErKviXhGL22qiGNgUMutvOYMyAsBK8=
gioui.org v0.0.0-20201018162216-7a4b48f67b54/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
gioui.org v0.0.0-20201224113856-0416fffc096b h1:S5tOnnkKUhmtF9cuCtD4IAVPXPItqpPIUQBISIQ60Uo=
gioui.org v0.0.0-20201224113856-0416fffc096b/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
gioui.org/cmd v0.0.0-20201020094634-d5bdf0756a5a h1:BPgJqeQSxuX6CzFQ2EGDj4Kr2ZzwiqwdLyAYLXgxR+k=
gioui.org/cmd v0.0.0-20201020094634-d5bdf0756a5a/go.mod h1:dlmJnCEkOpRaChYxRmJZ5S4jk6y7DCfWnec39xGbUYk=
git.sr.ht/~f4814n/matrix v0.0.0-20201215165513-ab5355096a5a h1:ajvU++oT9ggUUqPQ4LuNTv2BbZoWtbytZTkfPl4fZWA=
git.sr.ht/~f4814n/matrix v0.0.0-20201215165513-ab5355096a5a/go.mod h1:yR3YNkJR8S3qLkGh178oKRm3MnsT5cERNEXOF8eFOIo=
git.sr.ht/~f4814n/matrix v0.0.0-20201218143803-770e10bd6252 h1:82PU+gyoqJQWqdCZ5aefQ0YtIbcTlpCGQ1366UEChpc=
git.sr.ht/~f4814n/matrix v0.0.0-20201218143803-770e10bd6252/go.mod h1:yR3YNkJR8S3qLkGh178oKRm3MnsT5cERNEXOF8eFOIo=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=


@@ 56,11 54,7 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=


@@ 118,7 112,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

M util/rgb.go => util/rgb.go +7 -0
@@ 10,3 10,10 @@ func ARGB(c uint32) color.RGBA {
	return color.RGBA{A: uint8(c >> 24), R: uint8(c >> 16), G: uint8(c >> 8), B: uint8(c)}
}

func NRGB(c uint32) color.NRGBA {
	return NRGBA((0xff << 24) | c)
}

func NRGBA(c uint32) color.NRGBA {
	return color.NRGBA{A: uint8(c >> 24), R: uint8(c >> 16), G: uint8(c >> 8), B: uint8(c)}
}

M view/login/view.go => view/login/view.go +1 -1
@@ 97,7 97,7 @@ func (l *view) Layout(gtx layout.Context) layout.Dimensions {
				}

				lbl := material.Caption(l.theme, l.errorMessage)
				lbl.Color = util.RGB(0xff0000)
				lbl.Color = util.NRGB(0xff0000)
				return in.Layout(gtx, lbl.Layout)
			}),
			layout.Rigid(material.Button(l.theme, l.loginButton, "Login").Layout),

M view/memberlist/memberlist.go => view/memberlist/memberlist.go +1 -1
@@ 229,7 229,7 @@ func (v *view) topbar(gtx g) d {
	return layout.Stack{Alignment: layout.SW}.Layout(gtx,
		layout.Expanded(func(gtx g) d {
			gtx.Constraints.Min.X = gtx.Constraints.Max.X
			return fwidget.Fill{Color: v.theme.Color.Primary}.Layout(gtx)
			return fwidget.Fill{Color: v.theme.Palette.ContrastBg}.Layout(gtx)
		}),
		layout.Stacked(func(gtx g) d {
			return layout.Flex{Alignment: layout.Middle}.Layout(gtx,

M view/roomhistory/roomhistory.go => view/roomhistory/roomhistory.go +13 -13
@@ 161,7 161,7 @@ func (r *view) Layout(gtx g) d {

func (r *view) topbar(gtx g) d {
	return layout.Stack{Alignment: layout.SW}.Layout(gtx,
		layout.Expanded(fwidget.Fill{Color: r.theme.Color.Primary}.Layout),
		layout.Expanded(fwidget.Fill{Color: r.theme.Palette.ContrastBg}.Layout),
		layout.Stacked(func(gtx g) d {
			return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
				layout.Rigid(func(gtx g) d {


@@ 172,7 172,7 @@ func (r *view) topbar(gtx g) d {
				layout.Flexed(1, func(gtx g) d {
					gtx.Constraints.Min.X = gtx.Constraints.Max.X
					lbl := material.H6(r.theme, r.room.Displayname())
					lbl.Color = util.RGB(0xffffff)
					lbl.Color = util.NRGB(0xffffff)
					lbl.MaxLines = 1
					return lbl.Layout(gtx)
					// return d{Size: image.Point{X: gtx.Constraints.Max.X}}


@@ 264,7 264,7 @@ func (e event) Layout(gtx g) d {

func (e event) layoutStateEvent(gtx g) d {
	align := layout.Center
	bgcol := util.RGB(0xeeeeee)
	bgcol := util.NRGB(0xeeeeee)

	return align.Layout(gtx, func(gtx g) d {
		bg := fwidget.Background{


@@ 346,17 346,17 @@ func (e event) layoutStateEventContent(gtx g) d {
		return material.Body1(e.Theme, str).Layout(gtx)
	default:
		lbl := material.Body1(e.Theme, "[Unformattable Event]")
		lbl.Color = util.RGB(0xff0000)
		lbl.Color = util.NRGB(0xff0000)
		return lbl.Layout(gtx)
	}
}

func (e event) layoutRoomEvent(gtx g) d {
	align := layout.W
	bgcol := e.Theme.Color.Primary
	bgcol := e.Theme.Palette.ContrastBg
	if e.Own {
		align = layout.E
		bgcol = util.RGB(0xeeeeee)
		bgcol = util.NRGB(0xeeeeee)
	}

	return align.Layout(gtx, func(gtx g) d {


@@ 372,7 372,7 @@ func (e event) layoutRoomEvent(gtx g) d {
		}

		var msgWidth int
		timecol := util.ARGB(0xaaaaaaaa)
		timecol := util.NRGBA(0xaaaaaaaa)

		return bg.Layout(gtx, func(gtx g) d {
			return layout.Flex{Axis: layout.Vertical}.Layout(gtx,


@@ 422,21 422,21 @@ func (e event) layoutRoomEventContent(gtx g, msgWidth *int) d {

	if err != nil {
		lbl := material.Body2(e.Theme, err.Error())
		lbl.Color = util.RGB(0xff0000)
		lbl.Color = util.NRGB(0xff0000)
		content = lbl.Layout
	} else {
		switch e.Event.Base().Type {
		case "m.room.message":
			lbl := material.Body2(e.Theme, e.Event.(matrix.RoomEvent).Content["body"].(string))
			if e.Own {
				lbl.Color = util.RGB(0x000000)
				lbl.Color = util.NRGB(0x000000)
			} else {
				lbl.Color = util.RGB(0xffffff)
				lbl.Color = util.NRGB(0xffffff)
			}
			content = lbl.Layout
		default:
			lbl := material.Body1(e.Theme, "[Unformattable Event]")
			lbl.Color = util.RGB(0xff0000)
			lbl.Color = util.NRGB(0xff0000)
			content = lbl.Layout
		}
	}


@@ 506,7 506,7 @@ func (m *messageComposer) layoutEditor(gtx g, minHeight *int) d {
	gtx.Constraints.Min.X = gtx.Constraints.Max.X

	bg := fwidget.Background{
		Color:  util.RGB(0xeeeeee),
		Color:  util.NRGB(0xeeeeee),
		Inset:  layout.Inset{Left: unit.Dp(8), Right: unit.Dp(8)},
		Radius: unit.Dp(10),
	}


@@ 515,7 515,7 @@ func (m *messageComposer) layoutEditor(gtx g, minHeight *int) d {
		layout.Rigid(func(gtx g) d {
			if m.sendError != nil {
				lbl := material.Body2(m.theme, m.sendError.Error())
				lbl.Color = util.RGB(0xff0000)
				lbl.Color = util.NRGB(0xff0000)
				return lbl.Layout(gtx)
			}
			return d{}

M view/roomlist/roomlist.go => view/roomlist/roomlist.go +3 -3
@@ 69,7 69,7 @@ func (l *view) Layout(gtx layout.Context) layout.Dimensions {

func (l *view) topbar(gtx g) d {
	return layout.Stack{Alignment: layout.SW}.Layout(gtx,
		layout.Expanded(fwidget.Fill{Color: l.theme.Color.Primary}.Layout),
		layout.Expanded(fwidget.Fill{Color: l.theme.Palette.ContrastBg}.Layout),
		layout.Stacked(func(gtx g) d {
			return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
				layout.Rigid(func(gtx g) d {


@@ 200,7 200,7 @@ func (w *roomListElement) layoutIcon(gtx g) d {
}

func (w *roomListElement) layoutUpper(gtx g) d {
	bgtextcol := util.RGB(0xbbbbbb)
	bgtextcol := util.NRGB(0xbbbbbb)
	return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Baseline}.Layout(gtx,
		layout.Rigid(func(gtx g) d {
			lbl := material.H6(w.theme, w.room.Displayname())


@@ 222,7 222,7 @@ func (w *roomListElement) layoutUpper(gtx g) d {
}

func (w *roomListElement) layoutLastEvent(gtx g) d {
	bgtextcol := util.RGB(0xbbbbbb)
	bgtextcol := util.NRGB(0xbbbbbb)
	in := layout.Inset{Top: unit.Dp(6)}
	return in.Layout(gtx, func(gtx g) d {
		lbl := material.Body2(w.theme, formatEvent(w.lastEvent))

M widget/background.go => widget/background.go +13 -6
@@ 1,17 1,19 @@
package widget

import (
	"image"
	"image/color"
	"gioui.org/unit"

	"gioui.org/f32"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/op/clip"
	"gioui.org/f32"
	"gioui.org/op/paint"
	"gioui.org/unit"
)

type Background struct {
	Color  color.RGBA
	Color  color.NRGBA
	Radius unit.Value
	Inset  layout.Inset
}


@@ 36,10 38,15 @@ func (b *Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimensio
			}}, NW: r, NE: r, SW: r, SE: r,
		}.Add(gtx.Ops)
	}

	clip := clip.Rect{
		Max: image.Point{X: size.X, Y: size.Y},
	}
	paint.ColorOp{Color: b.Color}.Add(gtx.Ops)
	paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: width, Y: height}}}.Add(gtx.Ops)
	paint.PaintOp{}.Add(gtx.Ops)
	clip.Op().Add(gtx.Ops)

	macroCall.Add(gtx.Ops)
	stack.Pop()
	return dims
}


M widget/fill.go => widget/fill.go +9 -5
@@ 1,23 1,27 @@
package widget

import (
	"image"
	"image/color"

	"gioui.org/layout"
	"gioui.org/f32"
	"gioui.org/op/clip"
	"gioui.org/op/paint"
)

type Fill struct {
	Color color.RGBA
	Color color.NRGBA
}

func (f Fill) Layout(gtx layout.Context) layout.Dimensions {
	cs := gtx.Constraints
	d := cs.Min
	dr := f32.Rectangle{
		Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
	clip := clip.Rect{
		Max: image.Point{X: d.X, Y: d.Y},
	}
	clip.Add(gtx.Ops)
	paint.ColorOp{Color: f.Color}.Add(gtx.Ops)
	paint.PaintOp{Rect: dr}.Add(gtx.Ops)
	paint.PaintOp{}.Add(gtx.Ops)
	clip.Op().Add(gtx.Ops)
	return layout.Dimensions{Size: d, Baseline: d.Y}
}

M widget/list.go => widget/list.go +9 -10
@@ 3,12 3,13 @@ package widget
import (
	"image"
	"image/color"
	"git.sr.ht/~f4814n/frost/util"

	"gioui.org/gesture"
	"gioui.org/io/pointer"
	"gioui.org/layout"
	"gioui.org/widget/material"
	"gioui.org/unit"
	"gioui.org/gesture"
	"gioui.org/widget/material"
	"git.sr.ht/~f4814n/frost/util"
)

type IconListElement struct {


@@ 40,7 41,7 @@ func (w IconListElement) Layout(gtx g) d {
	})
}

var contactColors = []color.RGBA{
var contactColors = []color.NRGBA{
	{A: 0xff, R: 0xef, G: 0x6c, B: 0x00},
	{A: 0xff, R: 0x00, G: 0x57, B: 0x9b},
	{A: 0xff, R: 0x00, G: 0x97, B: 0xa7},


@@ 49,10 50,9 @@ var contactColors = []color.RGBA{
	{A: 0xff, R: 0x00, G: 0x89, B: 0x7b},
}


// InitialSign is a widget which shows a Initial on a colored background
type InitialSign struct {
	Theme *material.Theme
	Theme   *material.Theme
	Initial string
}



@@ 69,18 69,17 @@ func (w InitialSign) Layout(gtx layout.Context) layout.Dimensions {
			// Initial
			layout.Stacked(func(gtx g) d {
				lbl := material.H5(w.Theme, w.Initial)
				lbl.Color = util.RGB(0xffffff)
				lbl.Color = util.NRGB(0xffffff)
				return lbl.Layout(gtx)
			}),
		)
	})
}

func (w InitialSign) color() color.RGBA {
func (w InitialSign) color() color.NRGBA {
	return contactColors[w.Initial[0]%6]
}

func initialColor(initial byte) color.RGBA {
func initialColor(initial byte) color.NRGBA {
	return contactColors[initial%6]
}