fix null error when in full screen window
This commit is contained in:
parent
3b031b854b
commit
3a7abe6102
5 changed files with 89 additions and 52 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 0.0.6
|
||||
|
||||
* Fix null value error thrown in `MihPackageWindow` while in full screen mode.
|
||||
|
||||
## 0.0.5
|
||||
|
||||
* Add new icons to MihIcons pt2.
|
||||
|
|
|
|||
|
|
@ -97,6 +97,25 @@ class _ExampleMihPackageState extends State<ExampleMihPackage> {
|
|||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Icon(MihIcons.link),
|
||||
MihButton(
|
||||
width: 300,
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: true,
|
||||
windowTitle: "Full Screen Test",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Placeholder(),
|
||||
),
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.green(),
|
||||
child: Text("Press"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.5"
|
||||
version: "0.0.6"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -79,37 +79,52 @@ class MihPackageWindow extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MihPackageWindowState extends State<MihPackageWindow> {
|
||||
late double windowTitleSize;
|
||||
late double horizontralWindowPadding;
|
||||
late double verticalWindowPadding;
|
||||
late double windowWidth;
|
||||
late double windowHeight;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
void checkScreenSize(Size screenSize) {
|
||||
// print("screen width: $width");
|
||||
// print("screen height: $height");
|
||||
// late double windowTitleSize;
|
||||
// late double horizontralWindowPadding;
|
||||
// late double verticalWindowPadding;
|
||||
// late double windowWidth;
|
||||
// late double windowHeight;
|
||||
// late double width;
|
||||
// late double height;
|
||||
//
|
||||
// void checkScreenSize(Size screenSize) {
|
||||
// // print("screen width: $width");
|
||||
// // print("screen height: $height");
|
||||
// if (screenSize.width > 800) {
|
||||
// setState(() {
|
||||
// windowTitleSize = 25;
|
||||
// horizontralWindowPadding = width / 7;
|
||||
// verticalWindowPadding = 10;
|
||||
// windowWidth = width;
|
||||
// windowHeight = height;
|
||||
// });
|
||||
// } else {
|
||||
// setState(() {
|
||||
// windowTitleSize = 20;
|
||||
// horizontralWindowPadding = 10;
|
||||
// verticalWindowPadding = 10;
|
||||
// windowWidth = width;
|
||||
// windowHeight = height;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
Map<String, double> _getResponsiveDimensions(Size screenSize) {
|
||||
if (screenSize.width > 800) {
|
||||
setState(() {
|
||||
windowTitleSize = 25;
|
||||
horizontralWindowPadding = width / 7;
|
||||
verticalWindowPadding = 10;
|
||||
windowWidth = width;
|
||||
windowHeight = height;
|
||||
});
|
||||
return {
|
||||
'titleSize': 25.0,
|
||||
'horizontalPadding': screenSize.width / 7,
|
||||
'verticalPadding': 10.0,
|
||||
};
|
||||
} else {
|
||||
setState(() {
|
||||
windowTitleSize = 20;
|
||||
horizontralWindowPadding = 10;
|
||||
verticalWindowPadding = 10;
|
||||
windowWidth = width;
|
||||
windowHeight = height;
|
||||
});
|
||||
return {
|
||||
'titleSize': 20.0,
|
||||
'horizontalPadding': 10.0,
|
||||
'verticalPadding': 10.0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Widget getHeader() {
|
||||
Widget getHeader(double titleSize) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
|
@ -138,10 +153,9 @@ class _MihPackageWindowState extends State<MihPackageWindow> {
|
|||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: windowTitleSize,
|
||||
fontSize: titleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color:
|
||||
widget.foregroundColor ??
|
||||
color: widget.foregroundColor ??
|
||||
MihColors.secondary(darkMode: widget.darkMode),
|
||||
),
|
||||
),
|
||||
|
|
@ -178,45 +192,45 @@ class _MihPackageWindowState extends State<MihPackageWindow> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
checkScreenSize(size);
|
||||
final dimensions = _getResponsiveDimensions(size);
|
||||
|
||||
final double titleSize = dimensions['titleSize']!;
|
||||
final double horizontalPadding = dimensions['horizontalPadding']!;
|
||||
final double verticalPadding = dimensions['verticalPadding']!;
|
||||
|
||||
final bool isScrollbarOn = widget.scrollbarOn ?? false;
|
||||
return Dialog(
|
||||
insetPadding: EdgeInsets.symmetric(
|
||||
horizontal: horizontralWindowPadding,
|
||||
vertical: verticalWindowPadding,
|
||||
horizontal: horizontalPadding,
|
||||
vertical: verticalPadding,
|
||||
),
|
||||
insetAnimationCurve: Easing.emphasizedDecelerate,
|
||||
insetAnimationDuration: Durations.short1,
|
||||
child: Material(
|
||||
elevation: 10,
|
||||
shadowColor: Colors.black,
|
||||
color:
|
||||
widget.backgroundColor ??
|
||||
color: widget.backgroundColor ??
|
||||
MihColors.primary(darkMode: widget.darkMode),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: widget.borderOn == null || !widget.borderOn!
|
||||
? null
|
||||
: Border.all(
|
||||
color:
|
||||
widget.foregroundColor ??
|
||||
border: widget.borderOn == true
|
||||
? Border.all(
|
||||
color: widget.foregroundColor ??
|
||||
MihColors.secondary(darkMode: widget.darkMode),
|
||||
width: 5.0,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: widget.fullscreen
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
getHeader(),
|
||||
getHeader(titleSize),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: widget.scrollbarOn != null || !widget.scrollbarOn!
|
||||
child: !isScrollbarOn
|
||||
? widget.windowBody
|
||||
: MihSingleChildScroll(
|
||||
scrollbarOn: true,
|
||||
|
|
@ -228,19 +242,19 @@ class _MihPackageWindowState extends State<MihPackageWindow> {
|
|||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
getHeader(),
|
||||
getHeader(titleSize),
|
||||
const SizedBox(height: 5),
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 25,
|
||||
right: 25,
|
||||
bottom: verticalWindowPadding,
|
||||
bottom: verticalPadding,
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: windowHeight * 0.85,
|
||||
maxWidth: windowWidth * 0.85,
|
||||
maxHeight: size.height * 0.85,
|
||||
maxWidth: size.width * 0.85,
|
||||
),
|
||||
child: MihSingleChildScroll(
|
||||
scrollbarOn: true,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name: mih_package_toolkit
|
||||
description: "A comprehensive UI toolkit and utility library for building consistent MIH Packages within the MIH Project ecosystem."
|
||||
version: 0.0.5
|
||||
version: 0.0.6
|
||||
homepage: https://git.mzansi-innovation-hub.co.za/yaso_meth/mih_package_toolkit
|
||||
repository: https://git.mzansi-innovation-hub.co.za/yaso_meth/mih_package_toolkit
|
||||
issue_tracker: https://git.mzansi-innovation-hub.co.za/yaso_meth/mih_package_toolkit/issues
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue