marco.pms.mobileapp/lib/widgets/custom_switch.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

114 lines
3.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
import 'package:marco/helpers/widgets/my_spacing.dart';
class CustomSwitch extends StatefulWidget {
final bool value;
final ValueChanged<bool>? onChanged;
// final Color? activeTrackColor,
// inactiveTrackColor,
// activeThumbColor,
// inactiveThumbColor;
final double width, height;
final double thumbSize;
final double spacingOfThumbTrack;
final Color? activeBorderColor, inactiveBorderColor;
CustomSwitch({
super.key,
required this.value,
this.onChanged,
this.width = 56,
this.height = 28,
this.thumbSize = 22, // this.activeTrackColor,
// this.inactiveTrackColor,
// this.activeThumbColor,
// this.inactiveThumbColor,
this.spacingOfThumbTrack = 4,
this.activeBorderColor,
this.inactiveBorderColor,
});
CustomSwitch.normal({
super.key,
required this.value,
this.onChanged,
this.width = 48,
this.height = 24,
this.thumbSize = 20, // this.activeTrackColor,
// this.inactiveTrackColor,
// this.activeThumbColor,
// this.inactiveThumbColor,
this.spacingOfThumbTrack = 4,
this.activeBorderColor,
this.inactiveBorderColor,
});
CustomSwitch.small({
super.key,
required this.value,
this.onChanged,
this.width = 32,
this.height = 16,
this.thumbSize = 13.5, // this.activeTrackColor,
// this.inactiveTrackColor,
// this.activeThumbColor,
// this.inactiveThumbColor,
this.spacingOfThumbTrack = 2.5,
this.activeBorderColor,
this.inactiveBorderColor,
});
@override
_CustomSwitchState createState() => _CustomSwitchState();
}
class _CustomSwitchState extends State<CustomSwitch>
with SingleTickerProviderStateMixin, UIMixin {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
// return Switch(value: true, onChanged: (v){});
return GestureDetector(
onTap: () {
if (widget.onChanged != null) {
widget.onChanged!(!widget.value);
}
},
child: Container(
width: widget.width,
height: widget.height,
padding: MySpacing.all(widget.spacingOfThumbTrack),
decoration: BoxDecoration(
border: Border.all(
color: widget.value
? rightBarTheme.activeSwitchBorderColor
: rightBarTheme.onDisabled,
width: 0.6),
borderRadius: BorderRadius.circular(widget.height / 2),
color:
!widget.value ? rightBarTheme.disabled : colorScheme.primary),
child: Align(
alignment:
widget.value ? Alignment.centerRight : Alignment.centerLeft,
child: Container(
width: widget.thumbSize,
height: widget.thumbSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: !widget.value
? rightBarTheme.onDisabled
: colorScheme.onPrimary),
),
),
),
);
}
}