tooklit update pt1

This commit is contained in:
2026-03-20 09:35:49 +02:00
parent 865d9997e1
commit 98e9beb1cb
11 changed files with 191 additions and 41 deletions

View File

@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"app_settings","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/app_settings-7.0.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"local_auth_darwin","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/local_auth_darwin-1.6.0/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"app_settings","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/app_settings-7.0.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"flutter_plugin_android_lifecycle","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.31/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"local_auth_android","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/local_auth_android-1.0.52/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"],"dev_dependency":false}],"macos":[{"name":"app_settings","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/app_settings-7.0.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"local_auth_darwin","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/local_auth_darwin-1.6.0/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[],"windows":[{"name":"local_auth_windows","path":"/Users/yaso_meth/.pub-cache/hosted/pub.dev/local_auth_windows-1.0.11/","native_build":true,"dependencies":[],"dev_dependency":false}],"web":[]},"dependencyGraph":[{"name":"app_settings","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"local_auth","dependencies":["local_auth_android","local_auth_darwin","local_auth_windows"]},{"name":"local_auth_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"local_auth_darwin","dependencies":[]},{"name":"local_auth_windows","dependencies":[]}],"date_created":"2026-03-06 15:37:08.951498","version":"3.32.2","swift_package_manager_enabled":{"ios":false,"macos":false}} {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"app_settings","path":"/home/yaso/.pub-cache/hosted/pub.dev/app_settings-7.0.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"local_auth_darwin","path":"/home/yaso/.pub-cache/hosted/pub.dev/local_auth_darwin-1.6.0/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"app_settings","path":"/home/yaso/.pub-cache/hosted/pub.dev/app_settings-7.0.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"flutter_plugin_android_lifecycle","path":"/home/yaso/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.31/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"local_auth_android","path":"/home/yaso/.pub-cache/hosted/pub.dev/local_auth_android-1.0.52/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"],"dev_dependency":false}],"macos":[{"name":"app_settings","path":"/home/yaso/.pub-cache/hosted/pub.dev/app_settings-7.0.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"local_auth_darwin","path":"/home/yaso/.pub-cache/hosted/pub.dev/local_auth_darwin-1.6.0/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[],"windows":[{"name":"local_auth_windows","path":"/home/yaso/.pub-cache/hosted/pub.dev/local_auth_windows-1.0.11/","native_build":true,"dependencies":[],"dev_dependency":false}],"web":[]},"dependencyGraph":[{"name":"app_settings","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"local_auth","dependencies":["local_auth_android","local_auth_darwin","local_auth_windows"]},{"name":"local_auth_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"local_auth_darwin","dependencies":[]},{"name":"local_auth_windows","dependencies":[]}],"date_created":"2026-03-12 12:08:37.721081","version":"3.32.4","swift_package_manager_enabled":{"ios":false,"macos":false}}

View File

@@ -18,20 +18,20 @@ class _MyAppState extends State<MyApp> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'Flutter Demo',
theme: ThemeData( // theme: ThemeData(
scaffoldBackgroundColor: MihColors.primary(), // scaffoldBackgroundColor: MihColors.primary(),
colorScheme: ColorScheme( // colorScheme: ColorScheme(
brightness: Brightness.dark, // brightness: Brightness.dark,
primary: MihColors.secondary(), // primary: MihColors.secondary(),
onPrimary: MihColors.primary(), // onPrimary: MihColors.primary(),
secondary: MihColors.primary(), // secondary: MihColors.primary(),
onSecondary: MihColors.secondary(), // onSecondary: MihColors.secondary(),
error: MihColors.red(), // error: MihColors.red(),
onError: MihColors.primary(), // onError: MihColors.primary(),
surface: MihColors.primary(), // surface: MihColors.primary(),
onSurface: MihColors.secondary(), // onSurface: MihColors.secondary(),
), // ),
), // ),
home: const HomePage(), home: const HomePage(),
); );
} }

View File

@@ -25,6 +25,8 @@ class _ExamplePackageState extends State<ExamplePackage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MihPackage( return MihPackage(
backgroundColor: MihColors.primary(),
titleColor: MihColors.secondary(),
packageActionButton: actionButton(), packageActionButton: actionButton(),
packageTools: tools(), packageTools: tools(),
packageToolBodies: toolBodies(), packageToolBodies: toolBodies(),
@@ -40,6 +42,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: () {
@@ -65,7 +68,12 @@ class _ExamplePackageState extends State<ExamplePackage> {
selectedbodyIndex = 1; selectedbodyIndex = 1;
}); });
}; };
return MihPackageTools(tools: temp, selectedIndex: selectedbodyIndex); return MihPackageTools(
toolColor: MihColors.green(),
onSelectedIconColor: MihColors.primary(),
tools: temp,
selectedIndex: selectedbodyIndex,
);
} }
List<Widget> toolBodies() { List<Widget> toolBodies() {

View File

@@ -13,6 +13,12 @@ import 'package:mih_package_toolkit/src/mih_colors.dart';
/// * Theme-aware styling that syncs with [MihColors]. /// * Theme-aware styling that syncs with [MihColors].
/// * Custom elevation and border radius. /// * Custom elevation and border radius.
class MihDateField extends StatefulWidget { class MihDateField extends StatefulWidget {
/// The primary color of the date picker
final Color? primaryColor;
/// The secondary color of the date picker
final Color? secondayColor;
/// The controller that handles the text being edited. /// The controller that handles the text being edited.
/// ///
/// The date will be stored in `YYYY-MM-DD` format. /// The date will be stored in `YYYY-MM-DD` format.
@@ -50,6 +56,8 @@ class MihDateField extends StatefulWidget {
required this.controller, required this.controller,
required this.labelText, required this.labelText,
required this.required, required this.required,
this.primaryColor,
this.secondayColor,
this.width, this.width,
this.height, this.height,
this.borderRadius, this.borderRadius,
@@ -79,6 +87,36 @@ class _MihDateFieldState extends State<MihDateField> {
: DateTime.now(), : DateTime.now(),
firstDate: DateTime(1900), firstDate: DateTime(1900),
lastDate: DateTime(2200), lastDate: DateTime(2200),
builder: (context, child) {
return Theme(
data: Theme.of(context).copyWith(
colorScheme: ColorScheme.fromSeed(
seedColor: widget.primaryColor ?? MihColors.primary(),
primary: widget.secondayColor ??
MihColors.secondary(), // Header & Selected Day
onPrimary: widget.primaryColor ??
MihColors.primary(), // Text on top of primary
surface:
widget.secondayColor ?? MihColors.secondary(), // Background
onSurface:
widget.secondayColor ?? MihColors.secondary(), // Text/Dates
),
datePickerTheme: DatePickerThemeData(
backgroundColor: widget.primaryColor ?? MihColors.primary(),
headerBackgroundColor:
widget.secondayColor ?? MihColors.secondary(),
headerForegroundColor: widget.primaryColor ?? MihColors.primary(),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
foregroundColor: widget.secondayColor ??
MihColors.secondary(), // Action buttons (OK/Cancel)
),
),
),
child: child!,
);
},
); );
if (picked != null) { if (picked != null) {
widget.controller.text = picked.toString().split(" ")[0]; widget.controller.text = picked.toString().split(" ")[0];

View File

@@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mih_package_toolkit/src/mih_colors.dart';
import 'package:mih_package_toolkit/src/mih_package_tools.dart'; import 'package:mih_package_toolkit/src/mih_package_tools.dart';
/// The core container for MIH application modules. /// The core container for MIH application modules.
@@ -29,6 +30,12 @@ import 'package:mih_package_toolkit/src/mih_package_tools.dart';
/// ) /// )
/// ``` /// ```
class MihPackage extends StatefulWidget { class MihPackage extends StatefulWidget {
/// The background color of the package
final Color? backgroundColor;
/// The title color of the package
final Color? titleColor;
/// The floating action button or primary action trigger for this package. /// The floating action button or primary action trigger for this package.
final Widget packageActionButton; final Widget packageActionButton;
@@ -41,8 +48,8 @@ class MihPackage extends StatefulWidget {
/// The list of main content widgets for each "page" of the package. /// The list of main content widgets for each "page" of the package.
final List<Widget> packageToolBodies; final List<Widget> packageToolBodies;
/// An optional drawer for secondary actions. /// An optional drawer for actions.
final Drawer? actionDrawer; final Widget? actionDrawer;
/// The initial page index to display. /// The initial page index to display.
final int selectedBodyIndex; final int selectedBodyIndex;
@@ -51,6 +58,8 @@ class MihPackage extends StatefulWidget {
final Function(int) onIndexChange; final Function(int) onIndexChange;
const MihPackage({ const MihPackage({
super.key, super.key,
this.backgroundColor,
this.titleColor,
required this.packageActionButton, required this.packageActionButton,
required this.packageTools, required this.packageTools,
required this.packageToolBodies, required this.packageToolBodies,
@@ -155,6 +164,7 @@ class _MihPackageState extends State<MihPackage>
return GestureDetector( return GestureDetector(
onTap: unfocusAll, onTap: unfocusAll,
child: Scaffold( child: Scaffold(
backgroundColor: widget.backgroundColor ?? MihColors.primary(),
drawer: widget.actionDrawer, drawer: widget.actionDrawer,
body: SafeArea( body: SafeArea(
bottom: false, bottom: false,
@@ -181,7 +191,8 @@ class _MihPackageState extends State<MihPackage>
child: FittedBox( child: FittedBox(
child: Text( child: Text(
widget.packageToolTitles[_currentIndex], widget.packageToolTitles[_currentIndex],
style: const TextStyle( style: TextStyle(
color: widget.titleColor,
fontSize: 23, fontSize: 23,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),

View File

@@ -23,6 +23,9 @@ class MihPackageAction extends StatefulWidget {
/// If null, the button will be disabled and appear greyed out. /// If null, the button will be disabled and appear greyed out.
final void Function()? onTap; final void Function()? onTap;
/// The Color of the Icon
final Color iconColor;
/// The size of the icon inside the button. /// The size of the icon inside the button.
final double iconSize; final double iconSize;
@@ -32,6 +35,7 @@ class MihPackageAction extends StatefulWidget {
super.key, super.key,
required this.icon, required this.icon,
required this.iconSize, required this.iconSize,
required this.iconColor,
required this.onTap, required this.onTap,
}); });
@@ -57,6 +61,7 @@ class _MihPackageActionState extends State<MihPackageAction> {
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
onPressed: widget.onTap, onPressed: widget.onTap,
icon: widget.icon, icon: widget.icon,
color: widget.iconColor,
); );
} }
} }

View File

@@ -1,4 +1,6 @@
import 'dart:io' show Platform;
import 'package:app_settings/app_settings.dart'; import 'package:app_settings/app_settings.dart';
import 'package:flutter/foundation.dart';
import 'package:local_auth/local_auth.dart'; import 'package:local_auth/local_auth.dart';
import 'package:mih_package_toolkit/src/mih_button.dart'; import 'package:mih_package_toolkit/src/mih_button.dart';
import 'package:mih_package_toolkit/src/mih_colors.dart'; import 'package:mih_package_toolkit/src/mih_colors.dart';
@@ -29,7 +31,9 @@ import 'package:mih_package_toolkit/src/mih_single_child_scroll.dart';
class MihPackageTile extends StatefulWidget { class MihPackageTile extends StatefulWidget {
/// The name of the package displayed below the icon. /// The name of the package displayed below the icon.
final String packageName; final String packageName;
// final String? ytVideoID; // final String? ytVideoID;
/// The icon of the package displayed above the name.
final Widget packageIcon; final Widget packageIcon;
/// The callback triggered when the tile is tapped. /// The callback triggered when the tile is tapped.
@@ -40,7 +44,9 @@ class MihPackageTile extends StatefulWidget {
/// The color of the [packageName] text. /// The color of the [packageName] text.
final Color textColor; final Color textColor;
// final bool? authenticateUser;
/// Does the package require local auth check before opennings.
final bool? authenticateUser;
const MihPackageTile({ const MihPackageTile({
super.key, super.key,
required this.onTap, required this.onTap,
@@ -49,7 +55,7 @@ class MihPackageTile extends StatefulWidget {
required this.packageIcon, required this.packageIcon,
required this.iconSize, required this.iconSize,
required this.textColor, required this.textColor,
// this.authenticateUser, this.authenticateUser,
}); });
@override @override
@@ -95,7 +101,6 @@ class _MihPackageTileState extends State<MihPackageTile> {
} else { } else {
authErrorPopUp(); authErrorPopUp();
} }
// print("Authenticated: $didBioAuth");
} catch (error) { } catch (error) {
authErrorPopUp(); authErrorPopUp();
} }
@@ -212,17 +217,17 @@ class _MihPackageTileState extends State<MihPackageTile> {
} }
Future<void> authenticateUser() async { Future<void> authenticateUser() async {
// if (widget.authenticateUser != null && if (widget.authenticateUser != null &&
// widget.authenticateUser! && widget.authenticateUser! &&
// !kIsWeb && !kIsWeb &&
// !Platform.isLinux) { !Platform.isLinux) {
// if (await isUserAuthenticated()) { if (await isUserAuthenticated()) {
// widget.onTap(); widget.onTap();
// } }
// } else { } else {
// widget.onTap(); widget.onTap();
// } }
widget.onTap(); // widget.onTap();
} }
@override @override

View File

@@ -95,8 +95,7 @@ class _MihPackageToolBodyState extends State<MihPackageToolBody> {
color: widget.backgroundColor, color: widget.backgroundColor,
borderRadius: BorderRadius.circular(25.0), borderRadius: BorderRadius.circular(25.0),
border: Border.all( border: Border.all(
color: color: widget.borderColor ??
widget.borderColor ??
MihColors.secondary(darkMode: widget.darkMode), MihColors.secondary(darkMode: widget.darkMode),
width: 3.0, width: 3.0,
), ),
@@ -105,7 +104,7 @@ class _MihPackageToolBodyState extends State<MihPackageToolBody> {
_innerBodyPadding = 0.0; _innerBodyPadding = 0.0;
return BoxDecoration( return BoxDecoration(
color: widget.backgroundColor, color: widget.backgroundColor,
borderRadius: BorderRadius.circular(25.0), borderRadius: BorderRadius.circular(0),
border: Border.all(color: widget.backgroundColor, width: 3.0), border: Border.all(color: widget.backgroundColor, width: 3.0),
); );
} }

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mih_package_toolkit/src/mih_colors.dart';
/// A horizontal toolbar used for navigation within a [MihPackage]. /// A horizontal toolbar used for navigation within a [MihPackage].
/// ///
@@ -33,6 +34,12 @@ import 'package:flutter/material.dart';
/// ``` /// ```
// ignore: must_be_immutable // ignore: must_be_immutable
class MihPackageTools extends StatefulWidget { class MihPackageTools extends StatefulWidget {
/// The selected button fill color and unselected icon color
final Color? toolColor;
/// The selected button fill color and unselected icon color
final Color? onSelectedIconColor;
/// A map where the key is the Icon widget and the value is the /// A map where the key is the Icon widget and the value is the
/// callback function triggered on tap. /// callback function triggered on tap.
final Map<Widget, void Function()?> tools; final Map<Widget, void Function()?> tools;
@@ -43,6 +50,8 @@ class MihPackageTools extends StatefulWidget {
int selectedIndex; int selectedIndex;
MihPackageTools({ MihPackageTools({
super.key, super.key,
this.toolColor,
this.onSelectedIconColor,
required this.tools, required this.tools,
required this.selectedIndex, required this.selectedIndex,
}); });
@@ -63,13 +72,24 @@ class _MihPackageToolsState extends State<MihPackageTools> {
temp.add( temp.add(
Visibility( Visibility(
visible: widget.selectedIndex != index, visible: widget.selectedIndex != index,
child: IconButton(onPressed: onTap, icon: icon), child: IconButton(
color: widget.toolColor ?? MihColors.secondary(),
onPressed: onTap,
icon: icon,
),
), ),
); );
temp.add( temp.add(
Visibility( Visibility(
visible: widget.selectedIndex == index, visible: widget.selectedIndex == index,
child: IconButton.filled(onPressed: onTap, icon: icon), child: IconButton.filled(
color: widget.onSelectedIconColor ?? MihColors.primary(),
onPressed: onTap,
icon: icon,
style: IconButton.styleFrom(
backgroundColor: widget.toolColor ?? MihColors.secondary(),
),
),
), ),
); );
index += 1; index += 1;

View File

@@ -28,6 +28,12 @@ import 'package:mih_package_toolkit/src/mih_colors.dart';
/// ) /// )
/// ``` /// ```
class MihTimeField extends StatefulWidget { class MihTimeField extends StatefulWidget {
/// The primary color of the date picker
final Color? primaryColor;
/// The secondary color of the date picker
final Color? secondayColor;
/// The controller that stores and displays the selected time string (HH:mm). /// The controller that stores and displays the selected time string (HH:mm).
final TextEditingController controller; final TextEditingController controller;
@@ -60,6 +66,8 @@ class MihTimeField extends StatefulWidget {
required this.controller, required this.controller,
required this.labelText, required this.labelText,
required this.required, required this.required,
this.primaryColor,
this.secondayColor,
this.width, this.width,
this.height, this.height,
this.borderRadius, this.borderRadius,
@@ -85,9 +93,57 @@ class _MihTimeFieldState extends State<MihTimeField> {
) )
: TimeOfDay.now(), : TimeOfDay.now(),
builder: (context, child) { builder: (context, child) {
return MediaQuery( return Theme(
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true), data: Theme.of(context).copyWith(
child: child as Widget, colorScheme: ColorScheme.fromSeed(
seedColor: widget.primaryColor ??
MihColors.primary(darkMode: widget.darkMode),
primary: widget.secondayColor ??
MihColors.secondary(darkMode: widget.darkMode),
onPrimary: widget.primaryColor ??
MihColors.primary(darkMode: widget.darkMode),
surface: widget.secondayColor ??
MihColors.secondary(darkMode: widget.darkMode),
onSurface: widget.primaryColor ??
MihColors.primary(darkMode: widget.darkMode),
),
timePickerTheme: TimePickerThemeData(
// The main dialog background
backgroundColor: widget.primaryColor ??
MihColors.primary(darkMode: widget.darkMode),
// The background of the clock dial
dialBackgroundColor: widget.secondayColor ??
MihColors.secondary(darkMode: widget.darkMode),
// The color of the clock hand
dialHandColor: widget.primaryColor ??
MihColors.primary(darkMode: widget.darkMode),
// The background color of the hour/minute input boxes
hourMinuteColor: widget.secondayColor ??
MihColors.secondary(darkMode: widget.darkMode),
// The text color inside the hour/minute input boxes
hourMinuteTextColor: widget.primaryColor ??
MihColors.primary(darkMode: widget.darkMode),
// The color of the keyboard/clock toggle icon
entryModeIconColor: widget.secondayColor ??
MihColors.secondary(darkMode: widget.darkMode),
// Styles for AM/PM toggle (if not using 24h format)
dayPeriodColor: widget.secondayColor ??
MihColors.secondary(darkMode: widget.darkMode),
dayPeriodTextColor: widget.primaryColor ??
MihColors.primary(darkMode: widget.darkMode),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
foregroundColor: widget.secondayColor ??
MihColors.secondary(darkMode: widget.darkMode),
),
),
),
// Wrap your MediaQuery inside the child of the Theme
child: MediaQuery(
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true),
child: child!,
),
); );
}, },
); );

View File

@@ -5,6 +5,14 @@ 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 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 issue_tracker: https://git.mzansi-innovation-hub.co.za/yaso_meth/mih_package_toolkit/issues
platforms:
android:
ios:
web:
linux:
macos:
windows:
environment: environment:
sdk: ^3.0.0 sdk: ^3.0.0
flutter: ">=3.0.0" flutter: ">=3.0.0"