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

361 lines
11 KiB
Dart

import 'package:marco/helpers/widgets/my_constant.dart';
import 'package:flutter/material.dart';
enum MyButtonType { elevated, outlined, text }
class MyButton extends StatelessWidget {
final MyButtonType? buttonType;
final ButtonStyle? style;
final VoidCallback? onPressed;
final bool? disabled;
final bool? block;
final bool soft;
final WidgetStateProperty<EdgeInsetsGeometry>? msPadding;
final EdgeInsetsGeometry? padding;
final WidgetStateProperty<double>? msElevation;
final double? elevation;
final WidgetStateProperty<EdgeInsetsGeometry>? msShape;
final OutlinedBorder? shape;
final BorderRadiusGeometry? borderRadius;
final double? borderRadiusAll;
final WidgetStateProperty<Color>? msBackgroundColor;
final Color? backgroundColor;
final WidgetStateProperty<BorderSide>? msSide;
final BorderSide? side;
final Color borderColor;
final MaterialTapTargetSize? tapTargetSize;
final WidgetStateProperty<Color>? msShadowColor;
final Color? shadowColor;
final Color? splashColor;
final Widget child;
MyButton(
{super.key,
this.onPressed,
required this.child,
this.msPadding,
this.padding,
this.msShape,
this.shape,
this.borderRadius,
this.borderRadiusAll = 0,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.elevated,
this.style,
this.msShadowColor,
this.msSide,
this.side,
this.borderColor = Colors.transparent,
this.disabled = false,
this.block = false,
this.soft = false,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
MyButton.rounded(
{super.key,
required this.onPressed,
required this.child,
this.msPadding,
this.padding,
this.msShape,
this.shape,
this.borderRadius,
this.borderRadiusAll,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.elevated,
this.style,
this.block = false,
this.msSide,
this.disabled = false,
this.side,
this.soft = false,
this.borderColor = Colors.transparent,
this.msShadowColor,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
MyButton.small(
{super.key,
required this.onPressed,
required this.child,
this.msPadding,
this.padding = const EdgeInsets.fromLTRB(8, 4, 8, 4),
this.msShape,
this.shape,
this.borderRadius,
this.borderRadiusAll,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.elevated,
this.style,
this.block = false,
this.msSide,
this.soft = false,
this.disabled = false,
this.side,
this.borderColor = Colors.transparent,
this.msShadowColor,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
MyButton.medium(
{super.key,
required this.onPressed,
required this.child,
this.msPadding,
this.padding = const EdgeInsets.fromLTRB(24, 16, 24, 16),
this.msShape,
this.block = false,
this.shape,
this.soft = false,
this.borderRadius,
this.borderRadiusAll,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.elevated,
this.style,
this.msSide,
this.disabled = false,
this.side,
this.borderColor = Colors.transparent,
this.msShadowColor,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
MyButton.text(
{super.key,
required this.onPressed,
required this.child,
this.msPadding,
this.padding = const EdgeInsets.all(0),
this.msShape,
this.block = false,
this.shape,
this.soft = false,
this.borderRadius,
this.borderRadiusAll,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.text,
this.style,
this.msSide,
this.disabled = false,
this.side,
this.borderColor = Colors.transparent,
this.msShadowColor,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
MyButton.block(
{super.key,
required this.onPressed,
required this.child,
this.msPadding,
this.padding = const EdgeInsets.fromLTRB(24, 16, 24, 16),
this.msShape,
this.block = true,
this.shape,
this.soft = false,
this.borderRadius,
this.borderRadiusAll,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.elevated,
this.style,
this.msSide,
this.disabled = false,
this.side,
this.borderColor = Colors.transparent,
this.msShadowColor,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
MyButton.outlined(
{super.key,
required this.onPressed,
required this.child,
this.msPadding,
this.padding = const EdgeInsets.fromLTRB(24, 16, 24, 16),
this.msShape,
this.soft = false,
this.shape,
this.borderRadius,
this.borderRadiusAll,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.outlined,
this.style,
this.msSide,
this.block = false,
this.side,
this.disabled = false,
this.borderColor = Colors.transparent,
this.msShadowColor,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
MyButton.large(
{super.key,
required this.onPressed,
required this.child,
this.msPadding,
this.padding = const EdgeInsets.fromLTRB(36, 20, 36, 20),
this.msShape,
this.shape,
this.soft = false,
this.borderRadius,
this.borderRadiusAll,
this.msBackgroundColor,
this.backgroundColor,
this.buttonType = MyButtonType.elevated,
this.style,
this.disabled = false,
this.msSide,
this.side,
this.block = false,
this.borderColor = Colors.transparent,
this.msShadowColor,
this.msElevation,
this.elevation = 4,
this.shadowColor,
this.tapTargetSize = MaterialTapTargetSize.padded,
this.splashColor});
@override
Widget build(BuildContext context) {
Widget button;
Color bgColor = backgroundColor ?? Theme.of(context).colorScheme.primary;
if (buttonType == MyButtonType.outlined) {
button = OutlinedButton(
onPressed: onPressed,
style: style ??
ButtonStyle(
tapTargetSize: tapTargetSize,
side: msSide ??
WidgetStateProperty.all(side ??
BorderSide(
color:
soft ? borderColor.withAlpha(100) : borderColor,
width: soft ? 0.8 : 1,
)),
overlayColor: WidgetStateProperty.all(
splashColor ?? (bgColor.withAlpha(40))),
backgroundColor: soft
? WidgetStateProperty.all(borderColor.withAlpha(40))
: null,
foregroundColor:
WidgetStateProperty.all(borderColor.withAlpha(40)),
shadowColor:
msShadowColor ?? WidgetStateProperty.all(shadowColor),
padding: msPadding ?? WidgetStateProperty.all(padding),
shape: WidgetStateProperty.all(shape ??
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
borderRadiusAll ?? MyConstant.constant.buttonRadius),
))),
child: child,
);
} else if (buttonType == MyButtonType.elevated) {
button = ElevatedButton(
style: style ??
ButtonStyle(
tapTargetSize: tapTargetSize,
visualDensity: VisualDensity.compact,
elevation: msElevation ??
WidgetStateProperty.resolveWith<double>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return 0;
} else if (states.contains(WidgetState.pressed)) {
return elevation! * 2;
} else if (states.contains(WidgetState.hovered)) {
return elevation! * 1.5;
}
return elevation!;
},
),
backgroundColor: msBackgroundColor ??
WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return bgColor.withAlpha(100);
}
return bgColor;
},
),
shadowColor: msShadowColor ??
WidgetStateProperty.all(shadowColor ?? bgColor),
padding: msPadding ?? WidgetStateProperty.all(padding),
overlayColor: WidgetStateProperty.all(splashColor ??
(Theme.of(context).colorScheme.onPrimary.withAlpha(36))),
shape: WidgetStateProperty.all(shape ??
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadiusAll ??
MyConstant.constant.buttonRadius),
))),
onPressed: onPressed,
child: child);
} else {
button = TextButton(
style: ButtonStyle(
overlayColor:
WidgetStateProperty.all(splashColor ?? (bgColor.withAlpha(40))),
padding: msPadding ?? WidgetStateProperty.all(padding),
shape: WidgetStateProperty.all(shape ??
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
borderRadiusAll ?? MyConstant.constant.buttonRadius),
)),
tapTargetSize: tapTargetSize),
onPressed: onPressed,
child: child,
);
}
return block!
? Row(
children: [
Expanded(child: button),
],
)
: button;
}
}