@@ -23,6 +23,7 @@ const (
23
23
RemoveButtonCss = "font-bold bg-red-500 p-2 rounded hover:bg-red-700 m-1"
24
24
LogoutButtonCss = "font-bold bg-amber-700 p-2 rounded mx-1 hover:bg-amber-900"
25
25
UpdateButtonCss = "bg-green-600 hover:bg-green-800 text-xl p-2 rounded bottom-4 right-4 fixed"
26
+ InstallButtonCss = "bg-green-600 hover:bg-green-800 p-2 rounded m-2"
26
27
)
27
28
28
29
type ErrorContainer struct {
@@ -143,6 +144,7 @@ func (b *RootContainer) Render() app.UI {
143
144
Location : "new" ,
144
145
AdditionalCss : "hover:bg-amber-800" ,
145
146
},
147
+ & InstallButton {},
146
148
).ID ("root-buttons-container" ).Class ("flex flex-col absolute top-4 right-4" ),
147
149
app .P ().Text ("Tracked flushes:" ).Class ("py-2" ),
148
150
& LoadingWidget {id : "flushes-loading" },
@@ -522,6 +524,7 @@ func (a *AboutContainer) Render() app.UI {
522
524
Location : "login" ,
523
525
AdditionalCss : "hover:bg-amber-800" ,
524
526
},
527
+ & InstallButton {},
525
528
).Class ("flex flex-col p-4 shadow-lg rounded-lg bg-zinc-800" ),
526
529
).Class (CenteringDivCss ).ID ("about-container" )
527
530
}
@@ -932,3 +935,30 @@ func (c *UpdateButton) Render() app.UI {
932
935
func (c * UpdateButton ) onUpdateClick (ctx app.Context , e app.Event ) {
933
936
ctx .Reload ()
934
937
}
938
+
939
+ type InstallButton struct {
940
+ app.Compo
941
+ name string
942
+ isAppInstallable bool
943
+ }
944
+
945
+ func (b * InstallButton ) OnMount (ctx app.Context ) {
946
+ b .isAppInstallable = ctx .IsAppInstallable ()
947
+ }
948
+ func (b * InstallButton ) OnAppInstallChange (ctx app.Context ) {
949
+ b .isAppInstallable = ctx .IsAppInstallable ()
950
+ }
951
+ func (b * InstallButton ) Render () app.UI {
952
+ return app .Div ().
953
+ Body (
954
+ app .If (b .isAppInstallable , func () app.UI {
955
+ return app .Button ().
956
+ Text ("Install App" ).
957
+ OnClick (b .onInstallButtonClicked ).
958
+ Class (InstallButtonCss )
959
+ }),
960
+ ).Class ("flex flex-col" )
961
+ }
962
+ func (b * InstallButton ) onInstallButtonClicked (ctx app.Context , e app.Event ) {
963
+ ctx .ShowAppInstallPrompt ()
964
+ }
0 commit comments