2022-12-26 20:26:30 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
2022-11-19 19:16:46 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-11-09 02:23:56 +00:00
|
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
|
2023-03-22 16:43:38 +00:00
|
|
|
const macOsGroupId = 'T69YZGT58U.relatica';
|
|
|
|
|
2022-11-09 02:23:56 +00:00
|
|
|
String randomId() => const Uuid().v4().toString();
|
2022-11-19 19:16:46 +00:00
|
|
|
|
2023-11-27 21:09:42 +00:00
|
|
|
final platformIsMobile = Platform.isIOS || Platform.isAndroid;
|
2022-12-26 20:26:30 +00:00
|
|
|
|
2023-11-27 21:09:42 +00:00
|
|
|
final platformHasCamera = platformIsMobile;
|
|
|
|
|
|
|
|
final platformIsDesktop = !platformIsMobile;
|
|
|
|
|
|
|
|
final useImagePicker = kIsWeb || platformIsMobile;
|
2022-12-26 20:26:30 +00:00
|
|
|
|
2024-06-20 20:52:24 +00:00
|
|
|
String appVersion = '';
|
|
|
|
|
2023-11-17 18:30:32 +00:00
|
|
|
const usePhpDebugging = false;
|
2023-03-20 13:58:02 +00:00
|
|
|
|
2023-04-13 14:30:09 +00:00
|
|
|
const maxViewPortalHeight = 750.0;
|
|
|
|
const maxViewPortalWidth = 750.0;
|
|
|
|
|
2023-05-08 18:24:45 +00:00
|
|
|
const maxProcessingMillis = 3;
|
|
|
|
const processingSleep = Duration(milliseconds: 1);
|
2024-11-26 03:51:19 +00:00
|
|
|
const apiCallTimeout = Duration(seconds: 90);
|
|
|
|
const oauthTimeout = Duration(seconds: 30);
|
2023-05-08 18:24:45 +00:00
|
|
|
|
2022-11-19 19:16:46 +00:00
|
|
|
Future<bool?> showConfirmDialog(BuildContext context, String caption) {
|
|
|
|
return showDialog<bool>(
|
|
|
|
context: context,
|
2023-03-11 04:23:44 +00:00
|
|
|
barrierDismissible: true,
|
2022-11-19 19:16:46 +00:00
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertDialog(
|
2023-04-30 00:42:11 +00:00
|
|
|
content: Text(caption),
|
2022-11-19 19:16:46 +00:00
|
|
|
actions: <Widget>[
|
|
|
|
ElevatedButton(
|
|
|
|
child: const Text('OK'),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context, true); // showDialog() returns true
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool?> showYesNoDialog(BuildContext context, String caption) {
|
|
|
|
return showDialog<bool>(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertDialog(
|
2023-04-30 00:42:11 +00:00
|
|
|
content: Text(caption),
|
2022-11-19 19:16:46 +00:00
|
|
|
actions: <Widget>[
|
|
|
|
ElevatedButton(
|
|
|
|
child: const Text('Yes'),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context, true); // showDialog() returns true
|
|
|
|
},
|
|
|
|
),
|
|
|
|
ElevatedButton(
|
|
|
|
child: const Text('No'),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context, false); // showDialog() returns false
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2023-01-30 06:04:50 +00:00
|
|
|
|
|
|
|
Future<String?> showChooseOptions(
|
|
|
|
BuildContext context,
|
|
|
|
String caption,
|
|
|
|
List<String> options,
|
|
|
|
) {
|
|
|
|
return showDialog<String?>(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertDialog(
|
2023-04-30 00:42:11 +00:00
|
|
|
content: Text(caption),
|
2023-01-30 06:04:50 +00:00
|
|
|
actions: options
|
|
|
|
.map((o) => ElevatedButton(
|
|
|
|
child: Text(o),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context, o); // showDialog() returns true
|
|
|
|
},
|
|
|
|
))
|
|
|
|
.toList());
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|