- 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.
114 lines
3.1 KiB
Dart
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),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|