| 
							
								 | 
							
							import 'package:connectivity/connectivity.dart';
 | 
						
						
						
						
							 | 
							
								 | 
							
							import 'package:queuing_system/core/base/locater.dart';
 | 
						
						
						
						
							 | 
							
								 | 
							
							import 'package:queuing_system/core/config/size_config.dart';
 | 
						
						
						
						
							 | 
							
								 | 
							
							import 'package:flutter/cupertino.dart';
 | 
						
						
						
						
							 | 
							
								 | 
							
							import 'package:flutter/material.dart';
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							class Utils {
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							  static TextStyle textStyle(context) =>
 | 
						
						
						
						
							 | 
							
								 | 
							
							      TextStyle(color: Theme.of(context).primaryColor);
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							  static Future<bool> checkConnection() async {
 | 
						
						
						
						
							 | 
							
								 | 
							
							    ConnectivityResult connectivityResult =
 | 
						
						
						
						
							 | 
							
								 | 
							
							        await (Connectivity().checkConnectivity());
 | 
						
						
						
						
							 | 
							
								 | 
							
							    if ((connectivityResult == ConnectivityResult.mobile) ||
 | 
						
						
						
						
							 | 
							
								 | 
							
							        (connectivityResult == ConnectivityResult.wifi)) {
 | 
						
						
						
						
							 | 
							
								 | 
							
							      return true;
 | 
						
						
						
						
							 | 
							
								 | 
							
							    } else {
 | 
						
						
						
						
							 | 
							
								 | 
							
							      return false;
 | 
						
						
						
						
							 | 
							
								 | 
							
							    }
 | 
						
						
						
						
							 | 
							
								 | 
							
							  }
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							  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;
 | 
						
						
						
						
							 | 
							
								 | 
							
							  }
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							  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(' ');
 | 
						
						
						
						
							 | 
							
								 | 
							
							  }
 | 
						
						
						
						
							 | 
							
								 | 
							
							
 | 
						
						
						
						
							 | 
							
								 | 
							
							  static getHeight() {
 | 
						
						
						
						
							 | 
							
								 | 
							
							    return SizeConfig.getHeightMultiplier()*7;
 | 
						
						
						
						
							 | 
							
								 | 
							
							  }
 | 
						
						
						
						
							 | 
							
								 | 
							
							}
 |