Skip to content

Commit 6b908c6

Browse files
[Feature] Add utility extensions (#11)
* feat: implement date time picker utils and extensions * feat: use file picker utils on the contact us * chore: resolve merge conflicts from develop branch * ref: refactor utils * chore: resolve merge conflicts from develop * chore: resolve merge conflicts from develop * chore: resolve merge conflicts from develop * feat: add file size and type validation for photo, image, video and files * feat: add permission util class * [Refactor] Add constant in particular feture const file and add doc comments on mime constants * [Refactor] Move constants to dedicated directory * [Refactor] Rename folder from feature to constant * [Refactor] Applied suggested PR changes and sorted localization keys alphabetically * [Feature] Add unit tests for datetime extensions utilities * [Fix] Ignore cacheoptions in mock Dio get requests and fix test failures * [Refactor] Applied ai suggested improvements in applicable areas of code * [Refactor] Applied suggested changes from PR comments * [Refactor] Rename file extension constants with dot prefix * [Refactor] Add clarity missing import * refactor: remove unused import from login bloc --------- Co-authored-by: vishaltsolguruz <vishalt@solguruz.com>
1 parent 0b106f1 commit 6b908c6

29 files changed

Lines changed: 1288 additions & 384 deletions

integration_test/presentation/login/login_screen_test.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ void main() {
2121

2222
when(() => mockResponse.statusCode).thenReturn(200);
2323
when(() => mockResponse.data).thenReturn(productsResponse);
24-
when(() => mockDio.get(any())).thenAnswer((_) async => mockResponse);
24+
when(
25+
() => mockDio.get(
26+
any(),
27+
options: any(named: 'options'), // ignore the CacheOptions in test
28+
),
29+
).thenAnswer((_) async => mockResponse);
2530
when(() => mockDio.interceptors).thenReturn(Interceptors());
2631
});
2732

lib/constants/constants.dart

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,51 @@ const String kLogFileName = 'app.log';
22

33
const kMimeTypeVideo = 'video/';
44
const kMimeTypeImage = 'image/';
5-
const kSVGExtension = '.svg';
6-
const kPNGExtension = '.png';
5+
const kSVGWithDot = '.svg';
6+
const kPNGWithDot = '.png';
77

8-
// Firebase auth exceptions
8+
const kPdf = 'pdf';
9+
const kText = 'txt';
10+
const kDoc = 'doc';
11+
const kMp4 = 'mp4';
12+
13+
/// MIME types for identifying PDF, TXT, Word DOC, and MP4 files
14+
const kPdfMimeType = 'application/pdf';
15+
const kTextMimeType = 'text/plain';
16+
const kDocMimeType = 'application/msword';
17+
const kVideoMimeType = 'video/mp4';
18+
19+
/// PDF files start with "%PDF-" as a magic number to identify real PDFs, and
20+
/// MP4/ISO media files contain "ftyp" near the header to verify valid media format
21+
const String kPdfFileSignature = '%PDF-';
22+
const String kFileTypeBoxSignature = 'ftyp';
23+
24+
/// Signature bytes that identify a Microsoft OLE Compound File (used by legacy
25+
/// Microsoft Office formats such as `.doc`, `.xls`, `.ppt`).
26+
/// We use this constant for file type detection/validation — e.g., to check
27+
/// whether a given file is a valid legacy Office document before processing.
28+
const List<int> kDocOleFileSignature = [
29+
0xD0,
30+
0xCF,
31+
0x11,
32+
0xE0,
33+
0xA1,
34+
0xB1,
35+
0x1A,
36+
0xE1,
37+
];
38+
39+
const String kSomethingWentWrong = 'Oops! Something went wrong';
40+
41+
// Chat messaging constants
42+
const String kHeroAnimationPrefix = 'fullscreen_image_0';
43+
44+
// Regex patterns
45+
final kEmailRegex = RegExp(
46+
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
47+
);
48+
49+
// Firebase Auth exception codes
950
const kFirebaseAuthWeakPasswordException = 'weak-password';
1051
const kFirebaseAuthUserNotFoundException = 'user-not-found';
1152
const kFirebaseAuthWrongPasswordException = 'wrong-password';
@@ -15,17 +56,12 @@ const kFirebaseAuthSessionExpiredException = 'session-expired';
1556
const kFirebaseAuthSessionEmailAlreadyInUse = 'email-already-in-use';
1657
const kFirebaseAuthRequiresRecentLogin = 'requires-recent-login';
1758

18-
const String kSomethingWentWrong = 'Oops! Something went wrong';
19-
20-
// Chat messaging constants
21-
const String kHereAnimationPrefix = 'fullscreen_image_0';
22-
23-
// Contact us constants
24-
final kEmailRegex = RegExp(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$');
25-
final kAllowedFileExtensions = ['pdf'];
26-
2759
// Network/SSL pinning constants
2860
const String kConnectionIsNotSecureError = 'Connection is not secure';
2961

3062
// Cache Api Response
3163
const String kApiCache = 'api_cache';
64+
65+
// Date formats
66+
const String kDefaultDateFormat = 'dd-MM-yyyy';
67+
const String kDefaultTimeFormat12Hour = 'hh:mm a';

0 commit comments

Comments
 (0)