amend window to always include menu

This commit is contained in:
2025-05-28 10:51:43 +02:00
parent 10b77eb51c
commit 6f5a28678b
31 changed files with 565 additions and 957 deletions

View File

@@ -49,6 +49,26 @@ class _PackageToolOneState extends State<PackageToolOne> {
return MihPackageWindow(
fullscreen: false,
windowTitle: "Test No Full",
menuOptions: [
SpeedDialChild(
child: Icon(
Icons.add,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
label: "Show New Window",
labelBackgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
labelStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
fontWeight: FontWeight.bold,
),
backgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
onTap: () {
// showTestWindow();
},
),
],
onWindowTapClose: () {
Navigator.of(context).pop();
},

View File

@@ -4,12 +4,14 @@ import 'package:mzansi_innovation_hub/main.dart';
class MihFloatingMenu extends StatefulWidget {
final IconData? icon;
final double? iconSize;
final AnimatedIconData? animatedIcon;
final SpeedDialDirection? direction;
final List<SpeedDialChild> children;
const MihFloatingMenu({
super.key,
this.icon,
this.iconSize,
this.animatedIcon,
this.direction,
required this.children,
@@ -22,26 +24,21 @@ class MihFloatingMenu extends StatefulWidget {
class _MihFloatingMenuState extends State<MihFloatingMenu> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
right: 5.0,
bottom: 5.0,
),
child: SpeedDial(
icon: widget.icon,
animatedIcon: widget.animatedIcon,
direction: widget.direction ?? SpeedDialDirection.up,
activeIcon: Icons.close,
backgroundColor: MzanziInnovationHub.of(context)!.theme.successColor(),
activeBackgroundColor:
MzanziInnovationHub.of(context)!.theme.errorColor(),
foregroundColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
overlayColor: Colors.black,
overlayOpacity: 0.5,
children: widget.children,
onOpen: () => debugPrint('OPENING DIAL'),
onClose: () => debugPrint('DIAL CLOSED'),
),
return SpeedDial(
icon: widget.icon,
buttonSize: Size(widget.iconSize ?? 56.0, widget.iconSize ?? 56.0),
animatedIcon: widget.animatedIcon,
direction: widget.direction ?? SpeedDialDirection.up,
activeIcon: Icons.close,
backgroundColor: MzanziInnovationHub.of(context)!.theme.successColor(),
activeBackgroundColor:
MzanziInnovationHub.of(context)!.theme.errorColor(),
foregroundColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
overlayColor: Colors.black,
overlayOpacity: 0.5,
children: widget.children,
onOpen: () => debugPrint('OPENING DIAL'),
onClose: () => debugPrint('DIAL CLOSED'),
);
}
}

View File

@@ -1,20 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
class MihPackageWindow extends StatefulWidget {
final String windowTitle;
final Widget windowBody;
final Widget? windowTools;
// final List<SpeedDialChild> menuOptions;
final List<SpeedDialChild>? menuOptions;
final void Function() onWindowTapClose;
final bool fullscreen;
const MihPackageWindow({
super.key,
required this.fullscreen,
required this.windowTitle,
this.windowTools,
// required this.menuOptions,
this.menuOptions,
required this.onWindowTapClose,
required this.windowBody,
});
@@ -54,66 +54,6 @@ class _MihPackageWindowState extends State<MihPackageWindow> {
}
}
Widget getWindowHeader() {
return Container(
// color: Colors.green,
alignment: Alignment.center,
height: 50,
child: Row(
children: [
Container(
// color: Colors.white,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(25), // Optional: rounds the corners
boxShadow: const [
BoxShadow(
color: Color.fromARGB(
60, 0, 0, 0), // 0.2 opacity = 51 in alpha (255 * 0.2)
spreadRadius: -5,
blurRadius: 5,
offset: Offset(0, 5),
),
],
),
child: IconButton.filled(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all<Color>(
MzanziInnovationHub.of(context)!.theme.errorColor()),
),
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
iconSize: 20,
onPressed: () {
widget.onWindowTapClose();
},
icon: const Icon(
Icons.close,
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
// color: Colors.pink,
child: Text(
widget.windowTitle,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: windowTitleSize,
fontWeight: FontWeight.bold,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
),
),
widget.windowTools != null ? widget.windowTools! : Container(),
],
),
);
}
@override
void dispose() {
super.dispose();
@@ -139,44 +79,139 @@ class _MihPackageWindowState extends State<MihPackageWindow> {
),
insetAnimationCurve: Easing.emphasizedDecelerate,
insetAnimationDuration: Durations.short1,
child: Container(
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: widget.fullscreen
? Column(
mainAxisSize: MainAxisSize.max,
children: [
getWindowHeader(),
Expanded(
child: SingleChildScrollView(child: widget.windowBody)),
],
)
: Column(
mainAxisSize: MainAxisSize.min,
children: [
getWindowHeader(),
Flexible(
child: Padding(
padding: EdgeInsets.only(
left: 25,
right: 25,
bottom: vertticalWindowPadding,
),
child: ConstrainedBox(
child: Stack(
children: [
Container(
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: widget.fullscreen
? Column(
mainAxisSize: MainAxisSize.max,
children: [
const SizedBox(height: 10),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Text(
widget.windowTitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: windowTitleSize,
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
),
),
),
],
),
const SizedBox(height: 5),
Expanded(
child:
SingleChildScrollView(child: widget.windowBody)),
],
)
: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 10),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Text(
widget.windowTitle,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: windowTitleSize,
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
),
),
),
],
),
const SizedBox(height: 5),
Flexible(
child: Padding(
padding: EdgeInsets.only(
left: 25,
right: 25,
bottom: vertticalWindowPadding,
),
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: windowHeight * 0.85,
maxWidth: windowWidth * 0.85,
),
child: MihSingleChildScroll(
child: widget.windowBody))),
child:
MihSingleChildScroll(child: widget.windowBody),
),
),
),
],
),
),
Positioned(
top: 10,
left: 10,
child: Container(
// color: Colors.white,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(25), // Optional: rounds the corners
boxShadow: const [
BoxShadow(
color: Color.fromARGB(
60, 0, 0, 0), // 0.2 opacity = 51 in alpha (255 * 0.2)
spreadRadius: -2,
blurRadius: 10,
offset: Offset(0, 5),
),
],
),
child: IconButton.filled(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all<Color>(
MzanziInnovationHub.of(context)!.theme.errorColor()),
),
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
iconSize: 20,
onPressed: () {
widget.onWindowTapClose();
},
icon: const Icon(
Icons.close,
),
),
),
),
Visibility(
visible:
widget.menuOptions != null || widget.menuOptions!.isNotEmpty,
child: Positioned(
top: 10,
right: 10,
child: MihFloatingMenu(
iconSize: 40,
animatedIcon: AnimatedIcons.menu_close,
direction: SpeedDialDirection.down,
children: widget.menuOptions != null ? widget.menuOptions! : [],
),
),
),
],
),
);
}