first commit for mih package toolkit
This commit is contained in:
62
example/lib/main.dart
Normal file
62
example/lib/main.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import 'package:example/package_structure/example_package.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
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',
|
||||
theme: ThemeData(
|
||||
scaffoldBackgroundColor: MihColors.primary(),
|
||||
colorScheme: ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: MihColors.secondary(),
|
||||
onPrimary: MihColors.primary(),
|
||||
secondary: MihColors.primary(),
|
||||
onSecondary: MihColors.secondary(),
|
||||
error: MihColors.red(),
|
||||
onError: MihColors.primary(),
|
||||
surface: MihColors.primary(),
|
||||
onSurface: MihColors.secondary(),
|
||||
),
|
||||
),
|
||||
home: const HomePage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: MihPackageTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const ExamplePackage()),
|
||||
);
|
||||
},
|
||||
packageName: "Example Package",
|
||||
packageIcon: Icon(MihIcons.mihLogo, color: MihColors.secondary()),
|
||||
iconSize: 150,
|
||||
textColor: MihColors.secondary(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
74
example/lib/package_structure/example_package.dart
Normal file
74
example/lib/package_structure/example_package.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'package:example/package_structure/package_tools/tool_body_one.dart';
|
||||
import 'package:example/package_structure/package_tools/tool_body_two.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();
|
||||
}
|
||||
|
||||
class _ExamplePackageState extends State<ExamplePackage> {
|
||||
int selectedbodyIndex = 0; // Important for state management of the body
|
||||
late final ToolBodyOne _toolBodyOne;
|
||||
late final Widget _toolBodyTwo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_toolBodyOne = ToolBodyOne();
|
||||
_toolBodyTwo = ToolBodyTwo();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
packageActionButton: actionButton(),
|
||||
packageTools: tools(),
|
||||
packageToolBodies: toolBodies(),
|
||||
packageToolTitles: appToolTitles(),
|
||||
selectedBodyIndex: selectedbodyIndex,
|
||||
onIndexChange: (newIndex) {
|
||||
setState(() {
|
||||
selectedbodyIndex = newIndex;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget actionButton() {
|
||||
return MihPackageAction(
|
||||
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()?> temp = {};
|
||||
temp[const Icon(Icons.calculate)] = () {
|
||||
setState(() {
|
||||
selectedbodyIndex = 0;
|
||||
});
|
||||
};
|
||||
temp[const Icon(Icons.money)] = () {
|
||||
setState(() {
|
||||
selectedbodyIndex = 1;
|
||||
});
|
||||
};
|
||||
return MihPackageTools(tools: temp, selectedIndex: selectedbodyIndex);
|
||||
}
|
||||
|
||||
List<Widget> toolBodies() {
|
||||
return [_toolBodyOne, _toolBodyTwo];
|
||||
}
|
||||
}
|
||||
318
example/lib/package_structure/package_tools/tool_body_one.dart
Normal file
318
example/lib/package_structure/package_tools/tool_body_one.dart
Normal file
@@ -0,0 +1,318 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||
|
||||
class ToolBodyOne extends StatefulWidget {
|
||||
const ToolBodyOne({super.key});
|
||||
|
||||
@override
|
||||
State<ToolBodyOne> createState() => _ToolBodyOneState();
|
||||
}
|
||||
|
||||
class _ToolBodyOneState extends State<ToolBodyOne> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageToolBody(
|
||||
backgroundColor: MihColors.primary(),
|
||||
bodyItem: MihSingleChildScroll(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"This tool body is to showcase mih button, windows snackbar and colors",
|
||||
style: TextStyle(fontSize: 24, color: MihColors.secondary()),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.secondary(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Show Snackbar",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
backgroundColor: MihColors.red(),
|
||||
child: Text(
|
||||
"Hello from the snackbar",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.secondary(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Open Mih Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
showMihWindow(null, null, "Default Window");
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.grey(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Grey Button",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
showMihWindow(
|
||||
MihColors.grey(),
|
||||
MihColors.primary(),
|
||||
"Grey Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.green(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Green Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Green Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.green(),
|
||||
MihColors.primary(),
|
||||
"Green Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.red(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Red Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Red Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.red(),
|
||||
MihColors.primary(),
|
||||
"Red Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.pink(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Pink Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Pink Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.pink(),
|
||||
MihColors.primary(),
|
||||
"Pink Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.orange(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Orange Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Orange Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.orange(),
|
||||
MihColors.primary(),
|
||||
"Orange Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.yellow(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Yellow Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Yellow Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.yellow(),
|
||||
MihColors.primary(),
|
||||
"Yellow Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.bluishPurple(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Bluish Purple Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.secondary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Bluish Purple Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.bluishPurple(),
|
||||
MihColors.secondary(),
|
||||
"Bluish Purple Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.purple(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Purple Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Purple Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.purple(),
|
||||
MihColors.primary(),
|
||||
"Purple Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.gold(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Gold Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Gold Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.gold(),
|
||||
MihColors.primary(),
|
||||
"Gold Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.silver(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Silver Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Silver Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.silver(),
|
||||
MihColors.primary(),
|
||||
"Silver Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihButton(
|
||||
buttonColor: MihColors.bronze(),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Bronze Window",
|
||||
style: TextStyle(
|
||||
color: MihColors.primary(),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
debugPrint("Bronze Button Pressed");
|
||||
showMihWindow(
|
||||
MihColors.bronze(),
|
||||
MihColors.primary(),
|
||||
"Bronze Window",
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 50),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showMihWindow(Color? bdColor, Color? fgColor, String title) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
backgroundColor: bdColor,
|
||||
foregroundColor: fgColor,
|
||||
fullscreen: false,
|
||||
windowTitle: title,
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
windowBody: SizedBox(height: 500),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
126
example/lib/package_structure/package_tools/tool_body_two.dart
Normal file
126
example/lib/package_structure/package_tools/tool_body_two.dart
Normal file
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
|
||||
|
||||
class ToolBodyTwo extends StatefulWidget {
|
||||
const ToolBodyTwo({super.key});
|
||||
|
||||
@override
|
||||
State<ToolBodyTwo> createState() => _ToolBodyTwoState();
|
||||
}
|
||||
|
||||
class _ToolBodyTwoState extends State<ToolBodyTwo> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final FocusNode searchFocusNode = FocusNode();
|
||||
final _searchController = TextEditingController();
|
||||
final _textController = TextEditingController();
|
||||
final _dropdownController = TextEditingController();
|
||||
final _numericStepperController = TextEditingController();
|
||||
final _radioController = TextEditingController();
|
||||
final _dateController = TextEditingController();
|
||||
final _timeController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageToolBody(
|
||||
backgroundColor: MihColors.primary(),
|
||||
bodyItem: MihSingleChildScroll(
|
||||
child: MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
Text(
|
||||
"This tool body is to showcase mih iput fields with validation",
|
||||
style: TextStyle(fontSize: 24, color: MihColors.secondary()),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihSearchBar(
|
||||
width: 300,
|
||||
controller: _searchController,
|
||||
hintText: "Search...",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.secondary(),
|
||||
hintColor: MihColors.primary(),
|
||||
onPrefixIconTap: () {
|
||||
debugPrint(
|
||||
"Search initiated with query: ${_searchController.text}",
|
||||
);
|
||||
},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.secondary(),
|
||||
inputColor: MihColors.primary(),
|
||||
width: 300,
|
||||
controller: _textController,
|
||||
hintText: "Text Input",
|
||||
requiredText: true,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MihDropdownField(
|
||||
width: 300,
|
||||
controller: _dropdownController,
|
||||
hintText: "Dropdown Input",
|
||||
dropdownOptions: [
|
||||
"Option 1",
|
||||
"Option 2",
|
||||
"Option 3",
|
||||
"Option 4",
|
||||
"Option 5",
|
||||
"Option 6",
|
||||
],
|
||||
requiredText: true,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MihNumericStepper(
|
||||
width: 300,
|
||||
controller: _numericStepperController,
|
||||
fillColor: MihColors.secondary(),
|
||||
inputColor: MihColors.primary(),
|
||||
hintText: "Numeric Stepper",
|
||||
requiredText: true,
|
||||
validationOn: true,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MihRadioOptions(
|
||||
width: 300,
|
||||
controller: _radioController,
|
||||
hintText: "Radio Options",
|
||||
fillColor: MihColors.secondary(),
|
||||
secondaryFillColor: MihColors.primary(),
|
||||
requiredText: true,
|
||||
radioOptions: ["Option 1", "Option 2", "Option 3"],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MihToggle(
|
||||
width: 300,
|
||||
hintText: "Toggle",
|
||||
initialPostion: false,
|
||||
fillColor: MihColors.secondary(),
|
||||
secondaryFillColor: MihColors.primary(),
|
||||
onChange: (value) {
|
||||
debugPrint("Toggle changed: $value");
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MihDateField(
|
||||
width: 300,
|
||||
controller: _dateController,
|
||||
labelText: "Date Field",
|
||||
required: true,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MihTimeField(
|
||||
width: 300,
|
||||
controller: _timeController,
|
||||
labelText: "Time Field",
|
||||
required: true,
|
||||
),
|
||||
const SizedBox(height: 50),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user