forked from eatvio/eatvio_app
New screen names
This commit is contained in:
20
lib/core/app_export.dart
Normal file
20
lib/core/app_export.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
export 'package:connectivity_plus/connectivity_plus.dart';
|
||||
export 'package:flutter_bloc/flutter_bloc.dart';
|
||||
export 'package:eatvio_app/core/constants/constants.dart';
|
||||
export 'package:eatvio_app/core/errors/exceptions.dart';
|
||||
export 'package:eatvio_app/core/network/network_info.dart';
|
||||
export 'package:eatvio_app/core/utils/image_constant.dart';
|
||||
export 'package:eatvio_app/core/utils/logger.dart';
|
||||
export 'package:eatvio_app/core/utils/navigator_service.dart';
|
||||
export 'package:eatvio_app/core/utils/pref_utils.dart';
|
||||
export 'package:eatvio_app/core/utils/size_utils.dart';
|
||||
export 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart';
|
||||
export 'package:eatvio_app/localization/app_localization.dart';
|
||||
export 'package:eatvio_app/routes/app_routes.dart';
|
||||
export 'package:eatvio_app/theme/app_decoration.dart';
|
||||
export 'package:eatvio_app/theme/custom_text_style.dart';
|
||||
export 'package:eatvio_app/theme/theme_helper.dart';
|
||||
export 'package:eatvio_app/widgets/custom_image_view.dart';
|
||||
export '../theme/bloc/theme_bloc.dart';
|
||||
export '../theme/custom_button_style.dart';
|
||||
export 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
1
lib/core/constants/constants.dart
Normal file
1
lib/core/constants/constants.dart
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
26
lib/core/errors/exceptions.dart
Normal file
26
lib/core/errors/exceptions.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/main.dart';
|
||||
|
||||
class ServerException implements Exception {}
|
||||
|
||||
class CacheException implements Exception {}
|
||||
|
||||
class NetworkException implements Exception {}
|
||||
|
||||
///can be used for throwing [NoInternetException]
|
||||
class NoInternetException implements Exception {
|
||||
late String _message;
|
||||
|
||||
NoInternetException([String message = 'NoInternetException Occurred']) {
|
||||
if (globalMessengerKey.currentState != null) {
|
||||
globalMessengerKey.currentState!
|
||||
.showSnackBar(SnackBar(content: Text(message)));
|
||||
}
|
||||
this._message = message;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return _message;
|
||||
}
|
||||
}
|
||||
8
lib/core/errors/failures.dart
Normal file
8
lib/core/errors/failures.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
abstract class Failure {}
|
||||
|
||||
// General failures
|
||||
class ServerFailure extends Failure {}
|
||||
|
||||
class CacheFailure extends Failure {}
|
||||
|
||||
class NetworkFailure extends Failure {}
|
||||
47
lib/core/network/network_info.dart
Normal file
47
lib/core/network/network_info.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
|
||||
// For checking internet connectivity
|
||||
abstract class NetworkInfoI {
|
||||
Future<bool> isConnected();
|
||||
|
||||
Future<ConnectivityResult> get connectivityResult;
|
||||
|
||||
Stream<ConnectivityResult> get onConnectivityChanged;
|
||||
}
|
||||
|
||||
class NetworkInfo implements NetworkInfoI {
|
||||
Connectivity connectivity;
|
||||
|
||||
static final NetworkInfo _networkInfo = NetworkInfo._internal(Connectivity());
|
||||
|
||||
factory NetworkInfo() {
|
||||
return _networkInfo;
|
||||
}
|
||||
|
||||
NetworkInfo._internal(this.connectivity) {
|
||||
connectivity = this.connectivity;
|
||||
}
|
||||
|
||||
///checks internet is connected or not
|
||||
///returns [true] if internet is connected
|
||||
///else it will return [false]
|
||||
@override
|
||||
Future<bool> isConnected() async {
|
||||
final result = await connectivity.checkConnectivity();
|
||||
if (result != ConnectivityResult.none) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// to check type of internet connectivity
|
||||
@override
|
||||
Future<ConnectivityResult> get connectivityResult async {
|
||||
return connectivity.checkConnectivity();
|
||||
}
|
||||
|
||||
//check the type on internet connection on changed of internet connection
|
||||
@override
|
||||
Stream<ConnectivityResult> get onConnectivityChanged =>
|
||||
connectivity.onConnectivityChanged;
|
||||
}
|
||||
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