You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
queuing_system/lib/utils/utils.dart

175 lines
5.4 KiB
Dart

import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/main.dart';
class Utils {
2 years ago
static getHeight() {
return SizeConfig.getHeightMultiplier() * 7;
}
static generateContactAdminMsg([err = null]) {
//TODO: Add translation
String localMsg = 'Something wrong happened, please contact the admin';
if (err != null) {
localMsg = localMsg + '\n \n' + err.toString();
}
return localMsg;
}
2 years ago
static Future<bool> checkConnection() async {
List<ConnectivityResult> connectivityResult = await (Connectivity().checkConnectivity());
int indexEthernet = connectivityResult.indexWhere((element) => element == ConnectivityResult.ethernet);
if (indexEthernet != -1) {
return true;
}
int indexWifi = connectivityResult.indexWhere((element) => element == ConnectivityResult.wifi);
if (indexWifi != -1) {
2 years ago
return true;
}
return false;
}
2 years ago
// static TextStyle textStyle(context) => TextStyle(color: Theme.of(context).primaryColor);
//
//
//
// static getCardBoxDecoration() {
// return BoxDecoration(
// borderRadius: BorderRadius.circular(10),
// color: Colors.white,
// shape: BoxShape.rectangle,
// boxShadow: [
// BoxShadow(
// color: Color(0xFF0000000D),
// spreadRadius: 10,
// blurRadius: 27,
// offset: Offset(0, -3), // changes position of shadow
// ),
// ],
// );
// }
//
// navigateToUpdatePage(String message, String androidLink, iosLink) {
// // locator<NavigationService>().pushAndRemoveUntil(
// // FadePage(
// // page: UpdatePage(
// // message: message,
// // androidLink: androidLink,
// // iosLink: iosLink,
// // ),
// // ),
// // );
//
// // Navigator.pushAndRemoveUntil(
// // AppGlobal.CONTEX,
// // FadePage(
// // page: UpdatePage(
// // message: message,
// // androidLink: androidLink,
// // iosLink: iosLink,
// // ),
// // ),
// // (r) => false);
// }
//
// static InputDecoration textFieldSelectorDecoration(String hintText, String selectedText, bool isDropDown, {Icon suffixIcon, Color dropDownColor}) {
// return InputDecoration(
// focusedBorder: OutlineInputBorder(
// borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
// borderRadius: BorderRadius.circular(8),
// ),
// enabledBorder: OutlineInputBorder(
// borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
// borderRadius: BorderRadius.circular(8),
// ),
// disabledBorder: OutlineInputBorder(
// borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
// borderRadius: BorderRadius.circular(8),
// ),
// hintText: selectedText != null ? selectedText : hintText,
// suffixIcon: isDropDown
// ? suffixIcon != null
// ? suffixIcon
// : Icon(
// Icons.arrow_drop_down,
// color: dropDownColor != null ? dropDownColor : Colors.black,
// )
// : null,
// hintStyle: TextStyle(
// fontSize: 14,
// color: Colors.grey.shade600,
// ),
// );
// }
//
// static BoxDecoration containerBorderDecoration(Color containerColor, Color borderColor, {double borderWidth = -1}) {
// return BoxDecoration(
// color: containerColor,
// shape: BoxShape.rectangle,
// borderRadius: BorderRadius.all(Radius.circular(8)),
// border: Border.fromBorderSide(BorderSide(
// color: borderColor,
// width: borderWidth == -1 ? 2.0 : borderWidth,
// )),
// );
// }
//
// /// hides the keyboard if its already open
// static hideKeyboard(BuildContext context) {
// FocusScope.of(context).unfocus();
// }
//
// static String capitalize(str) {
// if (str != "") {
// return "${str[0].toUpperCase()}${str.substring(1).toLowerCase()}";
// } else {
// return str;
// }
// }
//
// static bool isTextHtml(String text) {
// var htmlRegex = RegExp("<(“[^”]*”|'[^]*|[^'”>])*>");
// return htmlRegex.hasMatch(text);
// }
//
// static String timeFrom({Duration duration}) {
// String twoDigits(int n) => n.toString().padLeft(2, "0");
// String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
// String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
// return "$twoDigitMinutes:$twoDigitSeconds";
// }
//
// static String convertToTitleCase(String text) {
// if (text == null) {
// return null;
// }
//
// if (text.length <= 1) {
// return text.toUpperCase();
// }
//
// // Split string into multiple words
// final List<String> words = text.split(' ');
//
// // Capitalize first letter of each words
// final capitalizedWords = words.map((word) {
// if (word.trim().isNotEmpty) {
// final String firstLetter = word.trim().substring(0, 1).toUpperCase();
// final String remainingLetters = word.trim().substring(1).toLowerCase();
//
// return '$firstLetter$remainingLetters';
// }
// return '';
// });
//
// // Join/Merge all words back to one String
// return capitalizedWords.join(' ');
// }
//
}