|
@@ -0,0 +1,174 @@
|
|
|
+import 'package:fis_theme/theme.dart';
|
|
|
+import 'package:fis_ui/index.dart';
|
|
|
+import 'package:fis_ui/interface/interactive_container.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:get/get.dart';
|
|
|
+import 'package:vitalapp/pages/home/controller.dart';
|
|
|
+
|
|
|
+class TitleBarButtons extends StatefulWidget {
|
|
|
+ final VoidCallback onMinimize;
|
|
|
+ final VoidCallback onWindowClose;
|
|
|
+ final VoidCallback? onMaximize;
|
|
|
+ final Color iconColor;
|
|
|
+ final Color backgroundColor;
|
|
|
+ late final Color? hoverColor;
|
|
|
+ late final Color? hoverIconColor;
|
|
|
+
|
|
|
+ TitleBarButtons(
|
|
|
+ this.onMinimize,
|
|
|
+ this.onWindowClose,
|
|
|
+ this.onMaximize,
|
|
|
+ this.iconColor,
|
|
|
+ this.backgroundColor, {
|
|
|
+ Color? hoverColor,
|
|
|
+ Color? hoverIconColor,
|
|
|
+ }) {
|
|
|
+ if (hoverColor == null) {
|
|
|
+ this.hoverColor = FTheme.ins.colorScheme.secondary;
|
|
|
+ } else {
|
|
|
+ this.hoverColor = hoverColor;
|
|
|
+ }
|
|
|
+ if (hoverIconColor == null) {
|
|
|
+ this.hoverIconColor = iconColor;
|
|
|
+ } else {
|
|
|
+ this.hoverIconColor = hoverIconColor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ State<StatefulWidget> createState() {
|
|
|
+ return _TitleBarButtonsState();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class _TitleBarButtonsState extends State<TitleBarButtons> {
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return Container(
|
|
|
+ height: 40,
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.end,
|
|
|
+ children: [
|
|
|
+ HoverIconButton(
|
|
|
+ widget.iconColor,
|
|
|
+ widget.onMinimize,
|
|
|
+ FIcon(Icons.remove),
|
|
|
+ widget.backgroundColor,
|
|
|
+ hoverColor: widget.hoverColor,
|
|
|
+ hoverIconColor: widget.hoverIconColor,
|
|
|
+ ),
|
|
|
+ if (widget.onMaximize != null) ...[
|
|
|
+ HoverIconButton(
|
|
|
+ widget.iconColor,
|
|
|
+ widget.onMaximize!,
|
|
|
+ Obx(() {
|
|
|
+ var controller = Get.find<HomeController>();
|
|
|
+ if (!controller.state.isMaximized) {
|
|
|
+ return FIcon(Icons.crop_square);
|
|
|
+ } else {
|
|
|
+ return FIcon(Icons.filter_none);
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ widget.backgroundColor,
|
|
|
+ hoverColor: widget.hoverColor,
|
|
|
+ hoverIconColor: widget.hoverIconColor,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ HoverIconButton(
|
|
|
+ widget.iconColor,
|
|
|
+ widget.onWindowClose,
|
|
|
+ FIcon(Icons.close),
|
|
|
+ widget.backgroundColor,
|
|
|
+ hoverColor: Colors.red,
|
|
|
+ hoverIconColor: widget.hoverIconColor,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class HoverIconButton extends StatefulWidget {
|
|
|
+ final Color iconColor;
|
|
|
+ final Color backgroundColor;
|
|
|
+ final VoidCallback onPressed;
|
|
|
+ final Widget icon;
|
|
|
+
|
|
|
+ late final Color? hoverColor;
|
|
|
+ late final Color? hoverIconColor;
|
|
|
+ late final double? width;
|
|
|
+ late final double? height;
|
|
|
+
|
|
|
+ HoverIconButton(
|
|
|
+ this.iconColor,
|
|
|
+ this.onPressed,
|
|
|
+ this.icon,
|
|
|
+ this.backgroundColor, {
|
|
|
+ Color? hoverColor,
|
|
|
+ Color? hoverIconColor,
|
|
|
+ double? height,
|
|
|
+ double? width,
|
|
|
+ }) {
|
|
|
+ if (hoverColor == null) {
|
|
|
+ this.hoverColor = backgroundColor;
|
|
|
+ } else {
|
|
|
+ this.hoverColor = hoverColor;
|
|
|
+ }
|
|
|
+ this.height = height;
|
|
|
+ this.width = width;
|
|
|
+ if (hoverIconColor == null) {
|
|
|
+ this.hoverIconColor = iconColor;
|
|
|
+ } else {
|
|
|
+ this.hoverIconColor = hoverIconColor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @override
|
|
|
+ State<StatefulWidget> createState() {
|
|
|
+ return HoverIconButtonState();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class HoverIconButtonState extends State<HoverIconButton> {
|
|
|
+ Color _backgroundColor = Colors.transparent;
|
|
|
+ late Color _iconColor;
|
|
|
+ late final Color hoverColor;
|
|
|
+ late final Color hoverIconColor;
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ _iconColor = widget.iconColor;
|
|
|
+ hoverColor = widget.hoverColor ?? widget.backgroundColor;
|
|
|
+ hoverIconColor = widget.hoverIconColor ?? _iconColor;
|
|
|
+ super.initState();
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return MouseRegion(
|
|
|
+ onEnter: (event) {
|
|
|
+ setState(() {
|
|
|
+ _iconColor = hoverIconColor;
|
|
|
+ _backgroundColor = hoverColor;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onExit: (event) {
|
|
|
+ setState(() {
|
|
|
+ _iconColor = widget.iconColor;
|
|
|
+ _backgroundColor = widget.backgroundColor;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ child: Container(
|
|
|
+ width: widget.width,
|
|
|
+ height: widget.height,
|
|
|
+ color: _backgroundColor,
|
|
|
+ child: IconButton(
|
|
|
+ color: _iconColor,
|
|
|
+ onPressed: () {
|
|
|
+ widget.onPressed.call();
|
|
|
+ },
|
|
|
+ icon: widget.icon,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|