Support linux version of MIH

This commit is contained in:
2026-02-24 15:41:55 +02:00
parent ce2575035f
commit 6ad6b6ccbd
10 changed files with 81 additions and 18 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:mzansi_innovation_hub/main.dart';
@@ -134,7 +136,9 @@ class MihAlertServices {
),
const SizedBox(height: 15),
Text(
"To get the most out of MIH, we need your location. Please go to the site settings of the app and enable location services. Once you do that, we can start showing you relevant information based on your location.",
Platform.isLinux
? "To get the most out of MIH, we need your location. Please go to your System Settings and enable location services. Once you do that, we can start showing you relevant information based on your location."
: "To get the most out of MIH, we need your location. Please go to the site settings of the app and enable location services. Once you do that, we can start showing you relevant information based on your location.",
style: TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==

View File

@@ -55,10 +55,12 @@ class MihFileApi {
// Navigator.of(context).pop(); // Always pop loading dialog
}
KenLogger.success("File URL: $fileUrl");
if (AppEnviroment.getEnv() == "Dev" && isSkiaWeb) {
if (AppEnviroment.getEnv() == "Dev" && kIsWeb) {
fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
} else if (AppEnviroment.getEnv() == "Dev" && Platform.isIOS) {
fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
} else if (AppEnviroment.getEnv() == "Dev" && Platform.isLinux) {
fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
}
KenLogger.success("File URL: $fileUrl");
return fileUrl;

View File

@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
@@ -13,6 +15,12 @@ class MIHLocationAPI {
///if user has blocked permission (denied or denied forver), user will get error pop up.
///if user has granted permission (while in use), function will return Position object.
Future<Position?> getGPSPosition(BuildContext context) async {
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled && Platform.isLinux) {
// Direct the user to their System Settings
MihAlertServices().locationPermissionAlert(context);
return null;
}
print("Before checkPermission"); // Debug
LocationPermission permission = await Geolocator.checkPermission();
print("After checkPermission: $permission"); // Debug