marco.pms.mobileapp/lib/helpers/widgets/my_screen_media.dart
Vaibhav Surve a5dd5e19fc Add Windows runner implementation for Flutter application
- Created CMakeLists.txt for Flutter and runner components.
- Implemented resource script (Runner.rc) for application metadata.
- Developed main entry point (main.cpp) for the Windows application.
- Added FlutterWindow class to manage the Flutter view within a Win32 window.
- Implemented utility functions for console management and command line argument parsing.
- Established Win32Window class for high DPI-aware window handling.
- Included application icon and manifest for proper Windows integration.
- Set up build configurations and dependencies for the Flutter application on Windows.
2025-04-23 09:55:31 +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);
}
}