Compare commits
1 Commits
0.0.2
...
103dd50c0e
| Author | SHA1 | Date | |
|---|---|---|---|
| 103dd50c0e |
62
README.md
62
README.md
@@ -38,36 +38,18 @@ 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';
|
||||||
|
|
||||||
void main() {
|
class ExamplePackage extends StatefulWidget {
|
||||||
runApp(const MyApp());
|
const ExamplePackage({super.key});
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
|
||||||
const MyApp({super.key});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MyApp> createState() => _MyAppState();
|
State<ExamplePackage> createState() => _ExamplePackageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
class _ExamplePackageState extends State<ExamplePackage> {
|
||||||
@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(),
|
||||||
@@ -85,7 +67,6 @@ class _ExampleMihPackageState extends State<ExampleMihPackage> {
|
|||||||
|
|
||||||
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: () {
|
||||||
@@ -100,52 +81,29 @@ class _ExampleMihPackageState extends State<ExampleMihPackage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MihPackageTools tools() {
|
MihPackageTools tools() {
|
||||||
Map<Widget, void Function()?> toolList = {};
|
Map<Widget, void Function()?> temp = {};
|
||||||
toolList[const Icon(Icons.calculate)] = () {
|
temp[const Icon(Icons.calculate)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedbodyIndex = 0;
|
selectedbodyIndex = 0;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
toolList[const Icon(Icons.money)] = () {
|
temp[const Icon(Icons.money)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedbodyIndex = 1;
|
selectedbodyIndex = 1;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return MihPackageTools(
|
return MihPackageTools(tools: temp, selectedIndex: selectedbodyIndex);
|
||||||
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(
|
bodyItem: Center(child: Text("Tool Body One")),
|
||||||
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(
|
bodyItem: Center(child: Text("Tool Body Two")),
|
||||||
child: Text(
|
|
||||||
"Tool Body Two",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.primary(),
|
|
||||||
fontSize: 25,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
@@ -15,101 +16,31 @@ 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 ExampleMihPackage());
|
return MaterialApp(title: 'Flutter Demo', home: const HomePage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExampleMihPackage extends StatefulWidget {
|
class HomePage extends StatelessWidget {
|
||||||
const ExampleMihPackage({super.key});
|
const HomePage({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 Scaffold(
|
||||||
backgroundColor: MihColors.primary(),
|
body: Center(
|
||||||
packageActionButton: actionButton(),
|
child: MihPackageTile(
|
||||||
packageTools: tools(),
|
authenticateUser: true,
|
||||||
packageToolBodies: toolBodies(),
|
onTap: () {
|
||||||
packageToolTitles: appToolTitles(),
|
Navigator.push(
|
||||||
selectedBodyIndex: selectedbodyIndex,
|
context,
|
||||||
onIndexChange: (newIndex) {
|
MaterialPageRoute(builder: (context) => const ExamplePackage()),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ?? MihColors.secondary(),
|
color: widget.titleColor,
|
||||||
fontSize: 23,
|
fontSize: 23,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user