- 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.
97 lines
3.1 KiB
Dart
97 lines
3.1 KiB
Dart
import 'package:marco/helpers/theme/app_theme.dart';
|
|
import 'package:marco/helpers/widgets/my_flex_item.dart';
|
|
import 'package:marco/helpers/widgets/my_list_extension.dart';
|
|
import 'package:marco/helpers/widgets/my_responsive.dart';
|
|
import 'package:marco/helpers/widgets/my_screen_media.dart';
|
|
import 'package:marco/helpers/widgets/my_screen_media_type.dart';
|
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class MyFlex extends StatelessWidget {
|
|
final List<MyFlexItem> children;
|
|
final WrapAlignment wrapAlignment;
|
|
final WrapCrossAlignment wrapCrossAlignment;
|
|
final WrapAlignment runAlignment;
|
|
final bool contentPadding;
|
|
|
|
// final Map<ScreenMediaType, int>? flex;
|
|
final double? spacing, runSpacing;
|
|
|
|
const MyFlex(
|
|
{super.key,
|
|
required this.children,
|
|
this.wrapAlignment = WrapAlignment.start, // this.flex,
|
|
this.wrapCrossAlignment = WrapCrossAlignment.start,
|
|
this.runAlignment = WrapAlignment.start,
|
|
this.contentPadding = true,
|
|
this.spacing,
|
|
this.runSpacing});
|
|
|
|
getPadding(index, length) {
|
|
if (contentPadding) {
|
|
return MySpacing.x((spacing ?? flexSpacing) / 2);
|
|
} else {
|
|
return MySpacing.fromLTRB(index == 0 ? 0 : (spacing ?? flexSpacing) / 2,
|
|
0, index == length - 1 ? 0 : (spacing ?? flexSpacing) / 2, 0);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MyResponsive(
|
|
builder:
|
|
(BuildContext context, BoxConstraints constraints, screenMediaType) {
|
|
double width = constraints.maxWidth;
|
|
List<Widget> list = [];
|
|
for (List<MyFlexItem> lCol in getGrouped(screenMediaType)) {
|
|
list.addAll(lCol.mapIndexed((index, col) => Container(
|
|
width: getWidthFromFlex(
|
|
width,
|
|
col.flex[screenMediaType] ?? MyScreenMedia.flexColumns.toDouble(),
|
|
lCol.length,
|
|
spacing ?? flexSpacing),
|
|
padding: getPadding(index, lCol.length),
|
|
child: col,
|
|
)));
|
|
}
|
|
return Wrap(
|
|
crossAxisAlignment: wrapCrossAlignment,
|
|
alignment: wrapAlignment,
|
|
runAlignment: runAlignment,
|
|
runSpacing: (runSpacing ?? flexSpacing),
|
|
spacing: (spacing ?? 0),
|
|
children: list,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
List<List<MyFlexItem>> getGrouped(MyScreenMediaType type) {
|
|
List<List<MyFlexItem>> list = [];
|
|
double flexCount = 0;
|
|
List<MyFlexItem> iList = [];
|
|
for (MyFlexItem col in children) {
|
|
if (col.display[type]!.isBlock) {
|
|
double flex = col.flex[type]!;
|
|
if (flexCount + flex <= 12) {
|
|
iList.add(col);
|
|
flexCount += flex;
|
|
} else {
|
|
list.add(iList);
|
|
iList = [];
|
|
iList.add(col);
|
|
flexCount = flex;
|
|
}
|
|
}
|
|
}
|
|
if (iList.isNotEmpty) {
|
|
list.add(iList);
|
|
}
|
|
return list;
|
|
}
|
|
|
|
double getWidthFromFlex(double width, double flex, int items, double spacing) {
|
|
return (width * flex / MyScreenMedia.flexColumns).floorToDouble();
|
|
}
|
|
}
|