forked from eatvio/eatvio_app
New screen names
This commit is contained in:
17
lib/core/utils/date_time_utils.dart
Normal file
17
lib/core/utils/date_time_utils.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
const String dateTimeFormatPattern = 'dd/MM/yyyy';
|
||||
|
||||
extension DateTimeExtension on DateTime {
|
||||
/// Return a string representing [date] formatted according to our locale
|
||||
String format([
|
||||
String pattern = dateTimeFormatPattern,
|
||||
String? locale,
|
||||
]) {
|
||||
if (locale != null && locale.isNotEmpty) {
|
||||
initializeDateFormatting(locale);
|
||||
}
|
||||
return DateFormat(pattern, locale).format(this);
|
||||
}
|
||||
}
|
||||
16
lib/core/utils/image_constant.dart
Normal file
16
lib/core/utils/image_constant.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class ImageConstant {
|
||||
// Image folder path
|
||||
static String imagePath = 'assets/images';
|
||||
|
||||
// splash_screen images
|
||||
static String img2456927096976 = '$imagePath/img_2456927096976.svg';
|
||||
|
||||
// Common images
|
||||
static String imgArrowLeft = '$imagePath/img_arrow_left.svg';
|
||||
|
||||
static String imgLogoEatvio = '$imagePath/img_logo_eatvio.svg';
|
||||
|
||||
static String imgFavorite = '$imagePath/img_favorite.svg';
|
||||
|
||||
static String imageNotFound = 'assets/images/image_not_found.png';
|
||||
}
|
||||
15
lib/core/utils/logger.dart
Normal file
15
lib/core/utils/logger.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
class Logger {
|
||||
static LogMode _logMode = LogMode.debug;
|
||||
|
||||
static void init(LogMode mode) {
|
||||
Logger._logMode = mode;
|
||||
}
|
||||
|
||||
static void log(dynamic data, {StackTrace? stackTrace}) {
|
||||
if (_logMode == LogMode.debug) {
|
||||
print("Error: $data$stackTrace");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum LogMode { debug, live }
|
||||
28
lib/core/utils/navigator_service.dart
Normal file
28
lib/core/utils/navigator_service.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NavigatorService {
|
||||
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
static Future<dynamic> pushNamed(String routeName,
|
||||
{dynamic arguments}) async {
|
||||
return navigatorKey.currentState
|
||||
?.pushNamed(routeName, arguments: arguments);
|
||||
}
|
||||
|
||||
static void goBack() {
|
||||
return navigatorKey.currentState?.pop();
|
||||
}
|
||||
|
||||
static Future<dynamic> pushNamedAndRemoveUntil(String routeName,
|
||||
{bool routePredicate = false, dynamic arguments}) async {
|
||||
return navigatorKey.currentState?.pushNamedAndRemoveUntil(
|
||||
routeName, (route) => routePredicate,
|
||||
arguments: arguments);
|
||||
}
|
||||
|
||||
static Future<dynamic> popAndPushNamed(String routeName,
|
||||
{dynamic arguments}) async {
|
||||
return navigatorKey.currentState
|
||||
?.popAndPushNamed(routeName, arguments: arguments);
|
||||
}
|
||||
}
|
||||
38
lib/core/utils/pref_utils.dart
Normal file
38
lib/core/utils/pref_utils.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
//ignore: unused_import
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class PrefUtils {
|
||||
static SharedPreferences? _sharedPreferences;
|
||||
|
||||
PrefUtils() {
|
||||
// init();
|
||||
SharedPreferences.getInstance().then((value) {
|
||||
_sharedPreferences = value;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> init() async {
|
||||
_sharedPreferences ??= await SharedPreferences.getInstance();
|
||||
print('SharedPreference Initialized');
|
||||
}
|
||||
|
||||
///will clear all the data stored in preference
|
||||
void clearPreferencesData() async {
|
||||
_sharedPreferences!.clear();
|
||||
}
|
||||
|
||||
Future<void> setThemeData(String value) {
|
||||
return _sharedPreferences!.setString('themeData', value);
|
||||
}
|
||||
|
||||
String getThemeData() {
|
||||
try {
|
||||
return _sharedPreferences!.getString('themeData')!;
|
||||
} catch (e) {
|
||||
return 'primary';
|
||||
}
|
||||
}
|
||||
}
|
||||
36
lib/core/utils/progress_dialog_utils.dart
Normal file
36
lib/core/utils/progress_dialog_utils.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
|
||||
class ProgressDialogUtils {
|
||||
static bool isProgressVisible = false;
|
||||
|
||||
///common method for showing progress dialog
|
||||
static void showProgressDialog(
|
||||
{BuildContext? context, isCancellable = false}) async {
|
||||
if (!isProgressVisible &&
|
||||
NavigatorService.navigatorKey.currentState?.overlay?.context != null) {
|
||||
showDialog(
|
||||
barrierDismissible: isCancellable,
|
||||
context: NavigatorService.navigatorKey.currentState!.overlay!.context,
|
||||
builder: (BuildContext context) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 4,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
isProgressVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
///common method for hiding progress dialog
|
||||
static void hideProgressDialog() {
|
||||
if (isProgressVisible)
|
||||
Navigator.pop(
|
||||
NavigatorService.navigatorKey.currentState!.overlay!.context);
|
||||
isProgressVisible = false;
|
||||
}
|
||||
}
|
||||
52
lib/core/utils/size_utils.dart
Normal file
52
lib/core/utils/size_utils.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// This functions are responsible to make UI responsive across all the mobile devices.
|
||||
|
||||
MediaQueryData mediaQueryData = MediaQueryData.fromWindow(ui.window);
|
||||
|
||||
// These are the Viewport values of your Figma Design.
|
||||
// These are used in the code as a reference to create your UI Responsively.
|
||||
const num FIGMA_DESIGN_WIDTH = 375;
|
||||
const num FIGMA_DESIGN_HEIGHT = 812;
|
||||
const num FIGMA_DESIGN_STATUS_BAR = 0;
|
||||
|
||||
///This extension is used to set padding/margin (for the top and bottom side) & height of the screen or widget according to the Viewport height.
|
||||
extension ResponsiveExtension on num {
|
||||
///This method is used to get device viewport width.
|
||||
get _width {
|
||||
return mediaQueryData.size.width;
|
||||
}
|
||||
|
||||
///This method is used to get device viewport height.
|
||||
get _height {
|
||||
num statusBar = mediaQueryData.viewPadding.top;
|
||||
num bottomBar = mediaQueryData.viewPadding.bottom;
|
||||
num screenHeight = mediaQueryData.size.height - statusBar - bottomBar;
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
///This method is used to set padding/margin (for the left and Right side) & width of the screen or widget according to the Viewport width.
|
||||
double get h => ((this * _width) / FIGMA_DESIGN_WIDTH);
|
||||
|
||||
///This method is used to set padding/margin (for the top and bottom side) & height of the screen or widget according to the Viewport height.
|
||||
double get v =>
|
||||
(this * _height) / (FIGMA_DESIGN_HEIGHT - FIGMA_DESIGN_STATUS_BAR);
|
||||
|
||||
///This method is used to set smallest px in image height and width
|
||||
double get adaptSize {
|
||||
var height = v;
|
||||
var width = h;
|
||||
return height < width ? height.toDoubleValue() : width.toDoubleValue();
|
||||
}
|
||||
|
||||
///This method is used to set text font size according to Viewport
|
||||
double get fSize => adaptSize;
|
||||
}
|
||||
|
||||
extension FormatExtension on double {
|
||||
/// Return a [double] value with formatted according to provided fractionDigits
|
||||
double toDoubleValue({int fractionDigits = 2}) {
|
||||
return double.parse(this.toStringAsFixed(fractionDigits));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user