marco.pms.mobile/lib/helpers/widgets/my_screen_media.dart
Vaibhav Surve 99902e743c Flutter application
- Created generated_plugin_registrant.cc and generated_plugin_registrant.h to manage plugin registration.
- Added generated_plugins.cmake for plugin configuration in CMake.
- Implemented CMakeLists.txt for the Windows runner, defining build settings and dependencies.
- Created Runner.rc for application resources including versioning and icons.
- Developed flutter_window.cpp and flutter_window.h to manage the Flutter window lifecycle.
- Implemented main.cpp as the entry point for the Windows application.
- Added resource.h for resource definitions.
- Included app icon in resources.
- Created runner.exe.manifest for application settings.
- Developed utils.cpp and utils.h for console management and command line argument handling.
- Implemented win32_window.cpp and win32_window.h for high DPI-aware window management.
2025-04-17 12:30:38 +05:30

75 lines
2.0 KiB
Dart

import 'package:marco/helpers/widgets/my_display_type.dart';
import 'package:marco/helpers/widgets/my_screen_media_type.dart';
class MyScreenMedia {
static int flexColumns = 12;
static double flexSpacing = 24;
static MyScreenMediaType getTypeFromWidth(double width) {
for (var i in MyScreenMediaType.values) {
if (width < i.width) {
return i;
}
}
return MyScreenMediaType.xxl;
}
static Map<MyScreenMediaType, T> getFilledMedia<T>(
Map<MyScreenMediaType, T>? map, T defaultValue,
[bool reversed = false]) {
Map<MyScreenMediaType, T> d = {};
map ??= {};
List list = MyScreenMediaType.list;
if (reversed) {
list = list.reversed.toList();
}
for (var i = 0; i < list.length; i++) {
d[list[i]] =
map[list[i]] ?? (i > 0 ? d[list[i - 1]] : null) ?? defaultValue;
}
return d;
}
static Map<MyScreenMediaType, double> getFlexedDataFromString(String? string) {
string ??= "";
Map<MyScreenMediaType, double> d = {};
List<String> data = string.split(" ");
for (String item in data) {
for (var type in MyScreenMediaType.values) {
if (item.contains(type.className)) {
double? flex = double.tryParse(item.replaceAll("${type.className}-", ""));
if (flex != null) {
d[type] = flex;
break;
}
}
}
}
return getFilledMedia<double>(d, MyScreenMedia.flexColumns.toDouble());
}
static Map<MyScreenMediaType, MyDisplayType> getDisplayDataFromString(
String? string) {
string ??= "";
Map<MyScreenMediaType, MyDisplayType> d = {};
List<String> data = string.split(" ");
for (String item in data) {
for (var type in MyScreenMediaType.values) {
if (item.contains(type.className)) {
MyDisplayType displayType = MyDisplayType.fromString(
item.replaceAll("${type.className}-", ""));
d[type] = displayType;
break;
}
}
}
return getFilledMedia(d, MyDisplayType.block);
}
}