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:mih_package_toolkit/mih_package_toolkit.dart';
class ExamplePackage extends StatefulWidget {
const ExamplePackage({super.key});
@override
State<ExamplePackage> createState() => _ExamplePackageState();
void main() {
runApp(const MyApp());
}
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
Widget build(BuildContext context) {
return MihPackage(
backgroundColor: MihColors.primary(),
packageActionButton: actionButton(),
packageTools: tools(),
packageToolBodies: toolBodies(),
@@ -67,6 +85,7 @@ class _ExamplePackageState extends State<ExamplePackage> {
Widget actionButton() {
return MihPackageAction(
iconColor: MihColors.secondary(),
icon: Icon(Icons.arrow_back),
iconSize: 35,
onTap: () {
@@ -81,29 +100,52 @@ class _ExamplePackageState extends State<ExamplePackage> {
}
MihPackageTools tools() {
Map<Widget, void Function()?> temp = {};
temp[const Icon(Icons.calculate)] = () {
Map<Widget, void Function()?> toolList = {};
toolList[const Icon(Icons.calculate)] = () {
setState(() {
selectedbodyIndex = 0;
});
};
temp[const Icon(Icons.money)] = () {
toolList[const Icon(Icons.money)] = () {
setState(() {
selectedbodyIndex = 1;
});
};
return MihPackageTools(tools: temp, selectedIndex: selectedbodyIndex);
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")),
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")),
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:mih_package_toolkit/mih_package_toolkit.dart';
@@ -16,31 +15,101 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Demo', home: const HomePage());
return MaterialApp(title: 'Flutter Demo', home: const ExampleMihPackage());
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
class ExampleMihPackage extends StatefulWidget {
const ExampleMihPackage({super.key});
@override
State<ExampleMihPackage> createState() => _ExampleMihPackageState();
}
class _ExampleMihPackageState extends State<ExampleMihPackage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: MihPackageTile(
authenticateUser: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const ExamplePackage()),
);
},
packageName: "Example Package",
packageIcon: Icon(MihIcons.mihLogo, color: MihColors.primary()),
iconSize: 150,
textColor: MihColors.primary(),
),
),
return MihPackage(
backgroundColor: MihColors.primary(),
packageActionButton: actionButton(),
packageTools: tools(),
packageToolBodies: toolBodies(),
packageToolTitles: appToolTitles(),
selectedBodyIndex: selectedbodyIndex,
onIndexChange: (newIndex) {
setState(() {
selectedbodyIndex = newIndex;
});
},
);
}
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(
widget.packageToolTitles[_currentIndex],
style: TextStyle(
color: widget.titleColor,
color: widget.titleColor ?? MihColors.secondary(),
fontSize: 23,
fontWeight: FontWeight.w600,
),