Merge pull request '0.0.2 pt 2 - fix example MIH Package' (#10) from 0.0.2 into main

Reviewed-on: #10
This commit was merged in pull request #10.
This commit is contained in:
2026-03-20 09:54:20 +00:00
3 changed files with 144 additions and 33 deletions

View File

@@ -38,18 +38,36 @@ import 'package:mih_package_toolkit/mih_package_toolkit.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mih_package_toolkit/mih_package_toolkit.dart'; import 'package:mih_package_toolkit/mih_package_toolkit.dart';
class ExamplePackage extends StatefulWidget { void main() {
const ExamplePackage({super.key}); runApp(const MyApp());
@override
State<ExamplePackage> createState() => _ExamplePackageState();
} }
class _ExamplePackageState extends State<ExamplePackage> { class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Demo', home: const ExampleMihPackage());
}
}
class ExampleMihPackage extends StatefulWidget {
const ExampleMihPackage({super.key});
@override
State<ExampleMihPackage> createState() => _ExampleMihPackageState();
}
class _ExampleMihPackageState extends State<ExampleMihPackage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackage( return MihPackage(
backgroundColor: MihColors.primary(),
packageActionButton: actionButton(), packageActionButton: actionButton(),
packageTools: tools(), packageTools: tools(),
packageToolBodies: toolBodies(), packageToolBodies: toolBodies(),
@@ -67,6 +85,7 @@ class _ExamplePackageState extends State<ExamplePackage> {
Widget actionButton() { Widget actionButton() {
return MihPackageAction( return MihPackageAction(
iconColor: MihColors.secondary(),
icon: Icon(Icons.arrow_back), icon: Icon(Icons.arrow_back),
iconSize: 35, iconSize: 35,
onTap: () { onTap: () {
@@ -81,29 +100,52 @@ class _ExamplePackageState extends State<ExamplePackage> {
} }
MihPackageTools tools() { MihPackageTools tools() {
Map<Widget, void Function()?> temp = {}; Map<Widget, void Function()?> toolList = {};
temp[const Icon(Icons.calculate)] = () { toolList[const Icon(Icons.calculate)] = () {
setState(() { setState(() {
selectedbodyIndex = 0; selectedbodyIndex = 0;
}); });
}; };
temp[const Icon(Icons.money)] = () { toolList[const Icon(Icons.money)] = () {
setState(() { setState(() {
selectedbodyIndex = 1; selectedbodyIndex = 1;
}); });
}; };
return MihPackageTools(tools: temp, selectedIndex: selectedbodyIndex); return MihPackageTools(
tools: toolList,
toolColor: MihColors.secondary(),
onSelectedIconColor: MihColors.primary(),
selectedIndex: selectedbodyIndex,
);
} }
List<Widget> toolBodies() { List<Widget> toolBodies() {
return [ return [
MihPackageToolBody( MihPackageToolBody(
backgroundColor: MihColors.primary(), backgroundColor: MihColors.primary(),
bodyItem: Center(child: Text("Tool Body One")), bodyItem: Center(
child: Text(
"Tool Body One",
style: TextStyle(
color: MihColors.secondary(),
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
), ),
MihPackageToolBody( MihPackageToolBody(
backgroundColor: MihColors.secondary(), backgroundColor: MihColors.secondary(),
bodyItem: Center(child: Text("Tool Body Two")), bodyItem: Center(
child: Text(
"Tool Body Two",
style: TextStyle(
color: MihColors.primary(),
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
), ),
]; ];
} }

View File

@@ -1,4 +1,3 @@
import 'package:example/package_structure/example_package.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mih_package_toolkit/mih_package_toolkit.dart'; import 'package:mih_package_toolkit/mih_package_toolkit.dart';
@@ -16,31 +15,101 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Demo', home: const HomePage()); return MaterialApp(title: 'Flutter Demo', home: const ExampleMihPackage());
} }
} }
class HomePage extends StatelessWidget { class ExampleMihPackage extends StatefulWidget {
const HomePage({super.key}); const ExampleMihPackage({super.key});
@override
State<ExampleMihPackage> createState() => _ExampleMihPackageState();
}
class _ExampleMihPackageState extends State<ExampleMihPackage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return MihPackage(
body: Center( backgroundColor: MihColors.primary(),
child: MihPackageTile( packageActionButton: actionButton(),
authenticateUser: true, packageTools: tools(),
onTap: () { packageToolBodies: toolBodies(),
Navigator.push( packageToolTitles: appToolTitles(),
context, selectedBodyIndex: selectedbodyIndex,
MaterialPageRoute(builder: (context) => const ExamplePackage()), onIndexChange: (newIndex) {
); setState(() {
selectedbodyIndex = newIndex;
});
}, },
packageName: "Example Package",
packageIcon: Icon(MihIcons.mihLogo, color: MihColors.primary()),
iconSize: 150,
textColor: MihColors.primary(),
),
),
); );
} }
int selectedbodyIndex = 0; // Important for state management of the body
Widget actionButton() {
return MihPackageAction(
iconColor: MihColors.secondary(),
icon: Icon(Icons.arrow_back),
iconSize: 35,
onTap: () {
Navigator.pop(context);
},
);
}
List<String> appToolTitles() {
List<String> toolTitles = ["Tool 1", "Tool 2"];
return toolTitles;
}
MihPackageTools tools() {
Map<Widget, void Function()?> toolList = {};
toolList[const Icon(Icons.calculate)] = () {
setState(() {
selectedbodyIndex = 0;
});
};
toolList[const Icon(Icons.money)] = () {
setState(() {
selectedbodyIndex = 1;
});
};
return MihPackageTools(
tools: toolList,
toolColor: MihColors.secondary(),
onSelectedIconColor: MihColors.primary(),
selectedIndex: selectedbodyIndex,
);
}
List<Widget> toolBodies() {
return [
MihPackageToolBody(
backgroundColor: MihColors.primary(),
bodyItem: Center(
child: Text(
"Tool Body One",
style: TextStyle(
color: MihColors.secondary(),
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
),
MihPackageToolBody(
backgroundColor: MihColors.secondary(),
bodyItem: Center(
child: Text(
"Tool Body Two",
style: TextStyle(
color: MihColors.primary(),
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
),
];
}
} }

View File

@@ -192,7 +192,7 @@ class _MihPackageState extends State<MihPackage>
child: Text( child: Text(
widget.packageToolTitles[_currentIndex], widget.packageToolTitles[_currentIndex],
style: TextStyle( style: TextStyle(
color: widget.titleColor, color: widget.titleColor ?? MihColors.secondary(),
fontSize: 23, fontSize: 23,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),