-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from RunTerror/main
Folder structuring
- Loading branch information
Showing
67 changed files
with
709 additions
and
254 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:graphql/client.dart'; | ||
|
||
abstract class DataState<T> { | ||
final T? data; | ||
final OperationException? error; | ||
|
||
const DataState({this.data, this.error}); | ||
} | ||
|
||
class DataSuccess<T> extends DataState<T> { | ||
const DataSuccess(T data) : super(data: data); | ||
} | ||
|
||
class DataFailed<T> extends DataState<T> { | ||
const DataFailed(OperationException error) : super(error: error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class SharedPreferencesService { | ||
SharedPreferenceService() { | ||
init(); | ||
} | ||
|
||
late SharedPreferences _prefs; | ||
|
||
init() async { | ||
_prefs = await SharedPreferences.getInstance(); | ||
} | ||
|
||
Future<void> saveData(String key, dynamic value) async { | ||
try { | ||
if (value is String) { | ||
await _prefs.setString(key, value); | ||
} else if (value is int) { | ||
await _prefs.setInt(key, value); | ||
} else if (value is bool) { | ||
await _prefs.setBool(key, value); | ||
} else if (value is double) { | ||
await _prefs.setDouble(key, value); | ||
} else if (value is List<String>) { | ||
await _prefs.setStringList(key, value); | ||
} | ||
} catch (e) { | ||
debugPrint(e.toString()); | ||
} | ||
} | ||
|
||
Future<dynamic> loadData(String key) async { | ||
return _prefs.get(key); | ||
} | ||
|
||
Future deleteData(String key) async { | ||
return await _prefs.remove('key'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class SizeConfig { | ||
static late MediaQueryData _mediaQueryData; | ||
static late double screenWidth; | ||
static late double screenHeight; | ||
static double? blockSizeHorizontal; | ||
static double? blockSizeVertical; | ||
static double? paddingTop; | ||
|
||
static late double _safeAreaHorizontal; | ||
static late double _safeAreaVertical; | ||
static double? safeBlockHorizontal; | ||
static double? safeBlockVertical; | ||
|
||
void init(BuildContext context) { | ||
_mediaQueryData = MediaQuery.of(context); | ||
screenWidth = _mediaQueryData.size.width; | ||
screenHeight = _mediaQueryData.size.height; | ||
blockSizeHorizontal = screenWidth / 100; | ||
blockSizeVertical = screenHeight / 100; | ||
|
||
_safeAreaHorizontal = | ||
_mediaQueryData.padding.left + _mediaQueryData.padding.right; | ||
_safeAreaVertical = | ||
_mediaQueryData.padding.top + _mediaQueryData.padding.bottom; | ||
safeBlockHorizontal = (screenWidth - _safeAreaHorizontal) / 100; | ||
safeBlockVertical = (screenHeight - _safeAreaVertical) / 100; | ||
debugPrint("safeBlockHorizontal: $safeBlockHorizontal"); | ||
debugPrint("safeBlockVertical: $safeBlockVertical"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
abstract class UseCase<Type, Paramas> { | ||
Future<Type> call(Paramas paramas); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'dart:developer'; | ||
import 'package:connectivity_plus/connectivity_plus.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:graphql/client.dart'; | ||
|
||
class Utils { | ||
void showSnackBar(String message, BuildContext context, | ||
{Duration duration = const Duration(seconds: 2)}) { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
SnackBar( | ||
duration: duration, | ||
content: Text( | ||
message, | ||
style: TextStyle(color: Colors.black), | ||
), | ||
// backgroundColor: kLightBlue.withOpacity(0.8), | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.all( | ||
Radius.circular(10), | ||
), | ||
), | ||
behavior: SnackBarBehavior.floating, | ||
elevation: 5, | ||
), | ||
); | ||
} | ||
|
||
String filterException(OperationException exception) { | ||
// checking grapqhl exceptions | ||
if (exception.graphqlErrors.isNotEmpty) { | ||
return exception.graphqlErrors.first.message; | ||
} | ||
// checking link exception | ||
else if (exception.linkException != null) { | ||
log('Link Exception: ${exception.linkException!.originalStackTrace}'); | ||
return 'Server exception'; | ||
} else { | ||
return 'Network Error: The request could not be completed.'; | ||
} | ||
} | ||
|
||
Future<bool> checkInternetConnectivity() async { | ||
final connectivityResult = await (Connectivity().checkConnectivity()); | ||
|
||
if (connectivityResult == ConnectivityResult.mobile || | ||
connectivityResult == ConnectivityResult.wifi || | ||
connectivityResult == ConnectivityResult.ethernet) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
String? validateEmail(String? value) { | ||
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$'); | ||
if (value == null || value.isEmpty) { | ||
return 'Email address is required'; | ||
} else if (!emailRegex.hasMatch(value)) { | ||
return 'Enter a valid email address'; | ||
} | ||
return null; // Return null if the email is valid | ||
} | ||
|
||
String? validatePassword(String? value) { | ||
if (value == null || value.isEmpty) { | ||
return 'Password is required'; | ||
} else if (value.length < 8) { | ||
return '8-digit password is required'; | ||
} | ||
return null; | ||
} | ||
|
||
String? validateName(String? value) { | ||
if (value == null || value.isEmpty) { | ||
return 'Name is required'; | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class CustomTheme { | ||
static const String _fontFamily = | ||
'FuturaBold'; // Match the name in pubspec.yaml | ||
|
||
// Define your custom colors | ||
Color kYellow = Color(0xFFFDBB2C); | ||
Color kBlue = Color(0xFF222375); | ||
Color lightkBlue = Color(0xFF535393); | ||
Color kLightBlue = Color(0xFFE8F1F8); | ||
Color kBlack = Color(0xFF343434); | ||
Color shimmerSkeletonColor = Color(0xff4e4f91); | ||
Color hintColor = Colors.black54; | ||
|
||
// Define your custom theme data | ||
ThemeData myTheme = ThemeData( | ||
fontFamily: _fontFamily, | ||
// Define primary colors | ||
primaryColor: const Color(0xFF222375), | ||
hintColor: const Color.fromARGB(255, 105, 103, 103), | ||
|
||
// Define text themes | ||
textTheme: const TextTheme( | ||
displayLarge: TextStyle( | ||
fontSize: 19, | ||
fontWeight: FontWeight.bold, | ||
fontFamily: _fontFamily, | ||
color: Colors.white, | ||
), | ||
displayMedium: TextStyle( | ||
fontSize: 16, | ||
fontWeight: FontWeight.w800, | ||
fontFamily: _fontFamily, | ||
color: Colors.black, | ||
), | ||
bodyLarge: TextStyle( | ||
fontSize: 16, | ||
fontFamily: _fontFamily, | ||
color: Colors.white, | ||
), | ||
), | ||
|
||
// Define other theme properties such as fonts, buttons, etc. | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.