dowlnoad link on about page

This commit is contained in:
2024-10-16 08:57:42 +02:00
parent c3add695d2
commit cd868ab4f6
4 changed files with 54 additions and 1 deletions

View File

@@ -112,4 +112,6 @@ class MIHApiCalls {
//print(userPic);
return HomeArguments(userData, bUserData, busData, notifi, userPic);
}
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/mih_components/mih_inputs_and_buttons/mih_button.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_action.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_body.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_header.dart';
@@ -6,7 +7,7 @@ import 'package:patient_manager/mih_components/mih_layout/mih_layout_builder.dar
import 'package:patient_manager/mih_components/mih_layout/mih_tile.dart';
import 'package:patient_manager/main.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import "package:universal_html/js.dart" as js;
import 'dart:html' as html;
class MIHAbout extends StatefulWidget {
@@ -76,6 +77,22 @@ class _MIHAboutState extends State<MIHAbout> {
fontSize: 15,
),
),
const SizedBox(
height: 10,
),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () {
js.context.callMethod("presentAddToHome");
},
buttonText: "Install MIH",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Divider(),

View File

@@ -96,6 +96,7 @@
document.body.style.background = "transparent";
}
</script>
<script src="install_pwa.js" defer></script>
<!-- Splash screen -->
<!-- <script>
var dartPdfJsBaseUrl = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.2.146/";

View File

@@ -0,0 +1,33 @@
let deferredPrompt;
// add to homescreen
window.addEventListener("beforeinstallprompt", (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
});
function isDeferredNotNull() {
return deferredPrompt != null;
}
function presentAddToHome() {
if (deferredPrompt != null) {
// Update UI to notify the user they can add to home screen
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === "accepted") {
console.log("User accepted the A2HS prompt");
} else {
console.log("User dismissed the A2HS prompt");
}
deferredPrompt = null;
});
} else {
console.log("deferredPrompt is null");
return null;
}
}