Skip to content

Commit 6486cb8

Browse files
committed
Uuid view and utils, Optimize for tablet screen
1 parent 8e86a18 commit 6486cb8

12 files changed

Lines changed: 524 additions & 19 deletions

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
Let's try it now in your browser [Open Dev](https://jamalianpour.github.io/open-dev)
1515

16+
![OpenDev Dashboard](assets/screenshot/dashboard.png)
17+
1618
## Table of Contents
1719
1. [Features 🚀](#features)
1820
2. [Screenshots 📷](#screenshots)
@@ -24,28 +26,43 @@ Let's try it now in your browser [Open Dev](https://jamalianpour.github.io/open-
2426

2527
## Features 🚀
2628
- **JSON Parser and Converter to YAML:** Parse and show JSON in object viewer to read and search, Easily convert JSON data to YAML format for better readability and use in various applications.
29+
2730
- **XML Parser and Converter to JSON:** Transform XML data into JSON format effortlessly, making it easier to work with in JavaScript and other environments.
31+
2832
- **Cron Parser:** Interpret and validate cron expressions to ensure correct scheduling of automated tasks.
33+
2934
- **Unix Time Converter:** Convert Unix timestamps to human-readable dates and vice versa, simplifying the handling of time data.
35+
3036
- **README Helper and Real-time Viewer:** Create and preview README files in real-time to ensure your documentation looks perfect.
37+
3138
- **Developer News Based on RSS:** Stay updated with the latest developer news through RSS feeds from popular sources.
39+
3240
- **Base64 String/Image Encode/Decode:** Encode and decode Base64 strings and images for data processing and transmission.
41+
3342
- **JWT Debugger:** Decode and debug JSON Web Tokens (JWT) to verify token contents and ensure security it locally without internet connection.
43+
3444
- **Hash Generator:** Generate cryptographic hashes for strings to ensure data integrity and security.
45+
3546
- **Color Converter:** Convert colors between different formats (HEX, RGB, HSL) for design and development purposes.
47+
3648
- **RegExp Tester:** Test and debug regular expressions to ensure they match the intended patterns.
49+
3750
- **Lorem Ipsum Generator:** Generate placeholder text for your projects to fill in design layouts.
51+
3852
- **Password Generator:** Create secure, random passwords to enhance security.
53+
3954
- **QR Code Generator:** Generate QR codes from text or URLs for easy sharing and access.
55+
4056
- **Image Extensions Formatter:** Convert images between different file formats for compatibility and optimization.
57+
4158
- **URL Encode/Decode:** Encode and decode URLs to ensure proper formatting and transmission.
4259

60+
- **UUID Generator/Decoder:** Generate and decode UUIDs (Universally Unique Identifiers) for use in applications that require unique identifiers.
61+
4362

4463
## Screenshots 📷
4564
Here are some screenshots of Open Dev in action:
4665

47-
![OpenDev Dashboard](assets/screenshot/dashboard.png)
48-
4966
| Hash Generator | JSON Parser and Converter to YAML |
5067
| ------------------------------------------------------- | ---------------------------------------------- |
5168
| ![Hash Generator](assets/screenshot/Hash.png) | ![JSON Parser](assets/screenshot/json.png) |

lib/main.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
55
import 'package:flutter/material.dart';
66
import 'package:flutter_acrylic/flutter_acrylic.dart';
77
import 'package:open_dev/views/base_view.dart';
8+
import 'package:open_dev/views/size_error_view.dart';
89
import 'package:window_manager/window_manager.dart';
910

1011
import 'utils/color_schemes.g.dart';
@@ -58,7 +59,9 @@ class MyApp extends StatelessWidget {
5859
darkTheme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme),
5960
debugShowCheckedModeBanner: false,
6061
home: kIsWeb
61-
? Container(color: Colors.grey[900], child: const BaseView())
62+
? MediaQuery.sizeOf(context).width < 800
63+
? const SizeErrorView()
64+
: Container(color: Colors.grey[900], child: const BaseView())
6265
: const SafeArea(
6366
child: TitlebarSafeArea(
6467
child: BaseView(),

lib/utils/uuid_utils.dart

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import 'package:uuid/uuid.dart';
2+
3+
class UuidUtils {
4+
static String generateV4() {
5+
return const Uuid().v4();
6+
}
7+
8+
static String generateV5(String namespace, String name) {
9+
return const Uuid().v5(namespace, name);
10+
}
11+
12+
static String generateV6() {
13+
return const Uuid().v6();
14+
}
15+
16+
static String generateV7() {
17+
return const Uuid().v7();
18+
}
19+
20+
static String generateV8() {
21+
return const Uuid().v8();
22+
}
23+
24+
static String generateV1() {
25+
return const Uuid().v1();
26+
}
27+
28+
/// Decodes a UUID and extracts its version, variant, timestamp, clock sequence, and node.
29+
///
30+
/// - param `String` uuid - The UUID to decode.
31+
/// - return `Tuple` A tuple containing the version, variant, timestamp, clock sequence, and node.
32+
static (int, String, int, int, String) decode(String uuid) {
33+
// Parse the UUID to a list of bytes
34+
List<int> bytes = Uuid.parse(uuid);
35+
36+
// Extracting information from the UUID
37+
var version = bytes[6] >> 4; // Version is in the 7th byte
38+
var variant = (bytes[8] & 0xC0) >> 6; // Variant is in the 9th byte
39+
40+
// Extract timestamp (60 bits: 4 bits from byte 6, all bits from byte 7, 5, 4, 3, 2, and 1)
41+
var timestamp = ((bytes[6] & 0x0F) << 56) |
42+
(bytes[7] << 48) |
43+
(bytes[4] << 40) |
44+
(bytes[5] << 32) |
45+
(bytes[0] << 24) |
46+
(bytes[1] << 16) |
47+
(bytes[2] << 8) |
48+
bytes[3];
49+
50+
// UUID timestamp is in 100-nanosecond intervals since 1582-10-15
51+
// Convert to Unix epoch (1970-01-01)
52+
const UUID_EPOCH = 0x01B21DD213814000;
53+
timestamp -= UUID_EPOCH;
54+
var millisecondsSinceEpoch = timestamp ~/ 10000; // Convert to milliseconds
55+
56+
// Extract clock sequence
57+
var clockSeq = ((bytes[8] & 0x3F) << 8) | bytes[9];
58+
59+
// Extract node (MAC address)
60+
var node = [
61+
bytes[10].toRadixString(16).padLeft(2, '0'),
62+
bytes[11].toRadixString(16).padLeft(2, '0'),
63+
bytes[12].toRadixString(16).padLeft(2, '0'),
64+
bytes[13].toRadixString(16).padLeft(2, '0'),
65+
bytes[14].toRadixString(16).padLeft(2, '0'),
66+
bytes[15].toRadixString(16).padLeft(2, '0')
67+
].join(':');
68+
69+
String variantName = '';
70+
71+
if (variant == 0) {
72+
variantName = '0 (NCS backward compatibility)';
73+
} else if (variant == 1) {
74+
variantName = '1 (RFC 4122/DCE 1.1)';
75+
} else if (variant == 2) {
76+
variantName = '2 (Microsoft\'s GUIDs)';
77+
} else if (variant == 3) {
78+
variantName = '3 (Reserved for future use)';
79+
} else {
80+
variantName = 'Unknown';
81+
}
82+
83+
return (version, variantName, millisecondsSinceEpoch, clockSeq, node);
84+
}
85+
}

lib/views/base_view.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import 'readme_view.dart';
1919
import 'regex_view.dart';
2020
import 'unix_time_view.dart';
2121
import 'url_view.dart';
22+
import 'uuid_view.dart';
2223

2324
class BaseView extends StatefulWidget {
2425
const BaseView({super.key});
@@ -73,7 +74,8 @@ class _BaseViewState extends State<BaseView> {
7374
const PasswordView(),
7475
const QrView(),
7576
const ImageView(),
76-
const UrlView()
77+
const UrlView(),
78+
const UuidView(),
7779
],
7880
),
7981
),

lib/views/dashboard_view.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,39 @@ class DashboardView extends StatelessWidget {
466466
],
467467
),
468468
),
469+
Padding(
470+
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
471+
child: Row(
472+
children: [
473+
Expanded(
474+
child: Semantics(
475+
button: true,
476+
label:
477+
'UUID Generator/Decode | Generate and decode UUIDs (Universally Unique Identifiers) for use in applications that require unique identifiers.',
478+
child: DashboardCard(
479+
title: 'UUID Generator/Decode',
480+
description:
481+
'Generate and decode UUIDs (Universally Unique Identifiers) for use in applications that require unique identifiers.',
482+
icon: const Icon(
483+
CupertinoIcons.underline,
484+
size: 50,
485+
color: Colors.white60,
486+
),
487+
onTap: () {
488+
sideMenu.changePage(17);
489+
},
490+
),
491+
),
492+
),
493+
const SizedBox(
494+
width: 16,
495+
),
496+
const Expanded(
497+
child: SizedBox.shrink(),
498+
),
499+
],
500+
),
501+
),
469502
],
470503
),
471504
),

lib/views/size_error_view.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import 'package:flutter/material.dart';
2+
3+
class SizeErrorView extends StatelessWidget {
4+
const SizeErrorView({super.key});
5+
6+
@override
7+
Widget build(BuildContext context) {
8+
return Scaffold(
9+
body: Center(
10+
child: Column(
11+
crossAxisAlignment: CrossAxisAlignment.center,
12+
mainAxisAlignment: MainAxisAlignment.center,
13+
mainAxisSize: MainAxisSize.max,
14+
children: [
15+
Padding(
16+
padding: const EdgeInsets.all(8.0),
17+
child: Image.asset(
18+
'assets/logo/icon.png',
19+
width: 125,
20+
height: 125,
21+
),
22+
),
23+
const Padding(
24+
padding: EdgeInsets.all(16),
25+
child: Text(
26+
'Sorry but currently Open Dev is not supported on this device 📱. Please use a device with a larger screen 🖥️.',
27+
textAlign: TextAlign.center,
28+
style: TextStyle(fontSize: 18, height: 1.8),
29+
),
30+
),
31+
],
32+
),
33+
),
34+
);
35+
}
36+
}

0 commit comments

Comments
 (0)