Compare commits
345 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e5ce03e396 | |||
| c67529dbac | |||
| 84cb6b2e83 | |||
| 6e07a55885 | |||
| 8fb31695a8 | |||
| 4fafa35888 | |||
| 0cf9634c5d | |||
| 787a8057b2 | |||
| 5f911d51f9 | |||
| 8da29792b4 | |||
| 5e003a4d71 | |||
| fcf1bbbb15 | |||
| ff7f363983 | |||
| 843997e58c | |||
| 3778ebb261 | |||
| b1487839a7 | |||
| 221030eff3 | |||
| 5135629b33 | |||
| 281ea863e8 | |||
| 1c0dd6d328 | |||
| 07d4ba4afa | |||
| 6ad6b6ccbd | |||
| ce2575035f | |||
| baea2c9fdb | |||
| 27639cb964 | |||
| 1143d11054 | |||
| 213f3d418d | |||
| e33a62b909 | |||
| ebab9bae52 | |||
| 82c25c5406 | |||
| 3f0fc08a5c | |||
| f137ea41ac | |||
| a7effa3576 | |||
| 74341a9cc6 | |||
| c5267c0540 | |||
| d4ba3aaa03 | |||
| 103ccdc022 | |||
| f8a722eb50 | |||
| fdb28080e3 | |||
| 8a384921c5 | |||
| 4b47bf5288 | |||
| 141611b84d | |||
| a29d0afeb8 | |||
| eb93714022 | |||
| 071612a521 | |||
| 726a60ad25 | |||
| b897986c1f | |||
| 7d4d7fc713 | |||
| 91075255f4 | |||
| 5c2f19dcc4 | |||
| 58aebbeabe | |||
| 670480910b | |||
| 45c1b247d3 | |||
|
|
ecd24670e9 | ||
|
|
ab99518ff2 | ||
|
|
6ac6aff59e | ||
| 33ca7b613e | |||
|
|
e83b0b50ae | ||
|
|
bcd19de256 | ||
|
|
ae36879ec5 | ||
|
|
eda609cf7e | ||
|
|
e1744b09e3 | ||
| a3845df8bd | |||
| d7eebe152b | |||
| d8a807b43e | |||
| 5172017a54 | |||
| 535924691e | |||
| ca8e0f56ac | |||
| 63071325cb | |||
| 800cd635c2 | |||
| f46ce36861 | |||
| b69fd92b19 | |||
| 9e19dc0fa4 | |||
| 38c40e2dfe | |||
| 02bbc32d23 | |||
| 5b052a1fa9 | |||
| d5349d981c | |||
| d6c28b631a | |||
| 74c5276c94 | |||
| d5e349d218 | |||
| 44527c8f10 | |||
| fbb9d8573c | |||
| 010fc0bc74 | |||
| 45ac3f03e6 | |||
| eea3248525 | |||
| b945a34ad4 | |||
| e3ac1be71c | |||
| 3a955e67ef | |||
| 777043e2ca | |||
| 6a8b9c6902 | |||
| 07360dd308 | |||
| 7c59e2a5c8 | |||
| 0b57e10532 | |||
| 5681c6d73b | |||
| f44ff6443c | |||
| fe5b61f6bc | |||
| e7729a8ce8 | |||
| 227a2f7ae7 | |||
| f26c1eb01a | |||
| ca0f13a6df | |||
| 021a25f50c | |||
| 0a9f0c000e | |||
| 3ff670886c | |||
| a6d5e4ad35 | |||
| 456dff6402 | |||
| d3fdc83373 | |||
| 8704d4dd64 | |||
| 37920466ac | |||
| 56d54a3711 | |||
| aef501cd25 | |||
| 4f5761271c | |||
| 252e120b99 | |||
| b5c26c3e43 | |||
| 74be2fc559 | |||
| b519b99a91 | |||
| 72261af7b9 | |||
| ad96725478 | |||
| ef4c3102a9 | |||
| 9a75bcc810 | |||
| 586e67b369 | |||
| e8cae1a894 | |||
| cd8115c597 | |||
| 730c5d2bdf | |||
| cea8ccab5a | |||
| 4f168c5b0e | |||
| 99f8b1a3f9 | |||
| 30c06261c8 | |||
| c843c0a55d | |||
| 94ac83db9e | |||
| a3b8da5357 | |||
| 47bc23c029 | |||
| c16d8b6e91 | |||
| a6fe4499d0 | |||
| 004c2397c5 | |||
| d64193d1f8 | |||
| e330875c6f | |||
| 3d2addf1d6 | |||
| 3b6e1d22ec | |||
| ff913c0c54 | |||
| c45c933277 | |||
| 89d6999abf | |||
| 969ecf8fdc | |||
| ee7d3881e6 | |||
| cc3f18f7e2 | |||
| 08bfe1d417 | |||
| 3593011d6d | |||
| 5ae11f6625 | |||
| a61bca7d81 | |||
| fb3b033f45 | |||
| 91a2d0dd1e | |||
| 04c643561b | |||
| 526bd40255 | |||
| 1889f6cada | |||
| c1dd9a60f2 | |||
| ec869c54c3 | |||
| b440c0a42b | |||
| baa826c52c | |||
| 6b530529e3 | |||
| a633b52949 | |||
| c103d1979c | |||
| 82c01cb7bf | |||
| 43bc552698 | |||
| bb6a8e3090 | |||
| 565e9199d4 | |||
| c5de46040d | |||
| 934b1b2301 | |||
| 302152449f | |||
| 0f591bd111 | |||
|
|
ea04c000cf | ||
| a59d2bf336 | |||
| d5fcad8fa5 | |||
| 609828a26c | |||
| d0a5c6c858 | |||
| 4a293c0aa4 | |||
| d51d13a685 | |||
| bf6bda04a6 | |||
| b749dc62d9 | |||
| b82a5a72c7 | |||
| 56ab6bb950 | |||
| bb54605ddb | |||
| c4b3a12213 | |||
| 43d715f4f8 | |||
| a9d6ca1baa | |||
| dfcfced28f | |||
| d0474fed21 | |||
| f228307859 | |||
| ab9cbce41c | |||
| 70413cc294 | |||
| a4d510f023 | |||
| e99388711d | |||
| 00cd5488e3 | |||
| b69a52a5a8 | |||
| f5c05d7431 | |||
| 0403d8c4b5 | |||
| fb7bf4ad65 | |||
| 3417299989 | |||
| 66887d23f8 | |||
| f064730dcf | |||
| a49505c153 | |||
| 9d898d8dff | |||
| c517075197 | |||
| 2dc3396fcc | |||
| d318b17b18 | |||
| 4221ae73b9 | |||
| b49e93825e | |||
| 790bf0e4f8 | |||
| a0bd74b703 | |||
| 96daf77b45 | |||
| 77ffd95fb6 | |||
| 24cc7f64b5 | |||
| d76512c11f | |||
| e1e7542a6d | |||
| 121cde211f | |||
| b79decf04f | |||
| a26b826729 | |||
| cc3d1ae430 | |||
| 329e450f5b | |||
| 0a03b1c60c | |||
| 652d4bb2fd | |||
| 5903fcd31a | |||
| b0825fe7cb | |||
| 8a2debcaa8 | |||
| 609c8d46db | |||
| 1387fb1af5 | |||
| 1f73aa3b87 | |||
| 47ca6d7311 | |||
| 64443a5076 | |||
| 20d5bc4004 | |||
| 9257786191 | |||
| 66db154b02 | |||
| 5770f6c353 | |||
| c5713cf6e0 | |||
| 4fe544b35f | |||
| 6542f1c399 | |||
|
|
963a708ab8 | ||
|
|
2f0b11e5ba | ||
| d9b2598bca | |||
| 0c15bd3e90 | |||
| 0daffb5041 | |||
| 9485213d6e | |||
| 9a8f157451 | |||
| a6f6cdaace | |||
| effbac2c91 | |||
| f8de726959 | |||
| 01220144c3 | |||
| 3f93cc9a7a | |||
| 83a16bad79 | |||
| d2f93db580 | |||
| a3c1963d30 | |||
| 8e6ef25954 | |||
| 580fa027f2 | |||
| 9346cccd20 | |||
| 51f2435c33 | |||
| ba5772f3ac | |||
| 662d20617d | |||
| e6d1cf0268 | |||
| ed7c5a2269 | |||
| 98beb20827 | |||
| 76a54ce969 | |||
| c53f30035d | |||
| ec01e2212b | |||
| f840418caf | |||
| 76d24a8e2b | |||
| 821cbc0a0d | |||
| ea25598144 | |||
| 70fc306789 | |||
| ba46f38497 | |||
| 67692967c3 | |||
| cc51afadb3 | |||
| d9fb9dd758 | |||
| d75da5389a | |||
|
|
efaf9b3574 | ||
| 763c4cdb54 | |||
| b37f0f71db | |||
| 8ceb443964 | |||
| a87e52d22c | |||
| 46c281d288 | |||
| 5289cf8511 | |||
| 22ae804c2d | |||
| 1a7293fc12 | |||
| e318e03805 | |||
| 11b6ec9edb | |||
| 2a7e3e17ce | |||
| 9cbdc849b1 | |||
| 0cabe11ab7 | |||
| a561f4fa5f | |||
| 429e91b638 | |||
| c0d152002c | |||
| 1329c8aba4 | |||
| 52f9eb7ba6 | |||
| bcff545dd7 | |||
| 6a5b4f7f4b | |||
|
|
b2b9d8f046 | ||
|
|
4c39e9163b | ||
|
|
6541ac883f | ||
| ffe9f6e9fb | |||
| 8e6f3d7d45 | |||
| abd56d5a14 | |||
| cb25b932ba | |||
| 771d809ce2 | |||
| d6f1629485 | |||
| 39a42048c2 | |||
| 99d0fa4aa8 | |||
| 79ed959b42 | |||
| 23c3cf4173 | |||
| f548db7d82 | |||
| fd2f3a2138 | |||
| 1fe817919f | |||
| 656e1cd3d7 | |||
| a9ea3594b9 | |||
| 7de2cb7b36 | |||
| ac22e50eca | |||
| 9bd039ca25 | |||
| b0d38b4b11 | |||
| 926b749fa8 | |||
| b2ed1e0b51 | |||
| 3dc9ce30e6 | |||
| 91241aa399 | |||
| c79904d132 | |||
| 15106d0a00 | |||
| 2e69e1dd92 | |||
| c89932755f | |||
| 540e13dfe0 | |||
| d51603ff5d | |||
| 553d22dd6b | |||
| 5f5107ee99 | |||
| 6ecce1e9ff | |||
| 22d8c64994 | |||
| ebd78eb72b | |||
| f828ba1786 | |||
| bbadc58ab8 | |||
| a1b7a3ef28 | |||
| 7373a1b8cb | |||
| 0edbfadc90 | |||
| ef479b633d | |||
| 081e7d5533 | |||
| 18e8217ce1 | |||
| cadd51535e | |||
| ba394e7fea | |||
| 04c92804b8 | |||
|
|
a2d1bebca1 | ||
|
|
1a448572ea | ||
|
|
04b247aa99 | ||
|
|
aa0d756979 | ||
|
|
16f50f826b |
18
.gitignore
vendored
@@ -1,16 +1,14 @@
|
||||
# *database/auto.cnf
|
||||
# *database/binlog.index
|
||||
# *database/mysql.sock
|
||||
File_Storage
|
||||
database/
|
||||
mih_minio/
|
||||
mih_db/
|
||||
mih_git/
|
||||
mih_nginx/
|
||||
mih_monitor/
|
||||
mih_wp/
|
||||
certbot/
|
||||
Firebase-emulator/
|
||||
Mzansi_Mail/
|
||||
# database/ibdata1
|
||||
# database/mysql.ibd
|
||||
# database/undo*
|
||||
# database/#innodb_redo/#ib_redo*
|
||||
.venv
|
||||
google-chrome-stable_current_amd64.deb
|
||||
.env
|
||||
Frontend/android/app/.cxx/
|
||||
Frontend/android/app/.cxx/
|
||||
.DS_Store
|
||||
17
.vscode/launch.json
vendored
@@ -6,14 +6,25 @@
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug",
|
||||
"cwd": "Frontend",
|
||||
"cwd": "mih_ui",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"program": "lib/main_dev.dart"
|
||||
},
|
||||
{
|
||||
"name": "Debug (web)",
|
||||
"cwd": "mih_ui",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"program": "lib/main_dev.dart",
|
||||
"args": [
|
||||
"--web-port",
|
||||
"1995"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Profile",
|
||||
"cwd": "Frontend",
|
||||
"cwd": "mih_ui",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"flutterMode": "profile",
|
||||
@@ -21,7 +32,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Release",
|
||||
"cwd": "Frontend",
|
||||
"cwd": "mih_ui",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"flutterMode": "release",
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "8defaa71a77c16e8547abdbfad2053ce3a6e2d5b"
|
||||
channel: "stable"
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
base_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
- platform: android
|
||||
create_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
base_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
- platform: ios
|
||||
create_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
base_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
- platform: linux
|
||||
create_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
base_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
- platform: macos
|
||||
create_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
base_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
- platform: web
|
||||
create_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
base_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
- platform: windows
|
||||
create_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
base_revision: 8defaa71a77c16e8547abdbfad2053ce3a6e2d5b
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
||||
@@ -1,48 +0,0 @@
|
||||
# Install Operating system and dependencies
|
||||
#FROM ubuntu:22.04
|
||||
FROM debian:latest AS build-env
|
||||
|
||||
#ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update --fix-missing
|
||||
|
||||
RUN apt-get install -y curl git wget unzip gdb libstdc++6 libglu1-mesa fonts-droid-fallback
|
||||
# RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback
|
||||
RUN apt-get install python3 -y
|
||||
|
||||
# download Flutter SDK from Flutter Github repo
|
||||
RUN git clone -b flutter-3.32-candidate.0 https://github.com/flutter/flutter.git /usr/local/flutter
|
||||
# RUN git clone -b stable https://github.com/flutter/flutter.git /usr/local/flutter
|
||||
|
||||
# Set flutter environment path
|
||||
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
|
||||
#ENV PATH "$PATH:/home/developer/flutter/bin"
|
||||
|
||||
RUN flutter doctor -v
|
||||
|
||||
# Enable flutter web
|
||||
RUN flutter channel flutter-3.32-candidate.0
|
||||
# RUN flutter channel stable
|
||||
RUN flutter config --enable-web
|
||||
|
||||
# Copy files to container and build
|
||||
RUN mkdir /app/
|
||||
COPY . /app/
|
||||
|
||||
WORKDIR /app
|
||||
# RUN flutter upgrade
|
||||
RUN flutter build web --release -t ./lib/main_prod.dart
|
||||
# RUN flutter build web --release --web-renderer canvaskit -t ./lib/main_prod.dart
|
||||
|
||||
|
||||
# RUN cd ..
|
||||
|
||||
# WORKDIR /app/build/web/
|
||||
|
||||
EXPOSE 83
|
||||
|
||||
RUN ["chmod", "+x", "/app/server/server.sh"]
|
||||
|
||||
ENTRYPOINT [ "/app/server/server.sh"]
|
||||
|
||||
# RUN ["python3", "-u", "/app/server/MIH_web_server.py"]
|
||||
@@ -1,5 +0,0 @@
|
||||
package za.co.mzansiinnovationhub.mih
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity : FlutterActivity()
|
||||
|
Before Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#3A4454</color>
|
||||
</resources>
|
||||
@@ -1,32 +0,0 @@
|
||||
# flutter pub run flutter_launcher_icons
|
||||
flutter_launcher_icons:
|
||||
image_path: "lib/mih_components/mih_package_components/assets/images/app_icon/mih_app_icon.png"
|
||||
|
||||
android: "launcher_icon"
|
||||
# image_path_android: "assets/icon/icon.png"
|
||||
min_sdk_android: 21 # android min sdk min:16, default 21
|
||||
adaptive_icon_background: "#3A4454"
|
||||
adaptive_icon_foreground: "lib/mih_components/mih_package_components/assets/images/app_icon/mih_app_icon.png"
|
||||
# adaptive_icon_monochrome: "assets/icon/monochrome.png"
|
||||
|
||||
ios: true
|
||||
image_path_ios: "lib/mih_components/mih_package_components/assets/images/app_icon/mih_app_icon.png"
|
||||
remove_alpha_channel_ios: true
|
||||
# image_path_ios_dark_transparent: "assets/icon/icon_dark.png"
|
||||
# image_path_ios_tinted_grayscale: "assets/icon/icon_tinted.png"
|
||||
# desaturate_tinted_to_grayscale_ios: true
|
||||
|
||||
web:
|
||||
generate: true
|
||||
image_path: "lib/mih_components/mih_package_components/assets/images/app_icon/circle_logo.png"
|
||||
background_color: "#3A4454"
|
||||
theme_color: "#3A4454"
|
||||
|
||||
windows:
|
||||
generate: true
|
||||
image_path: "lib/mih_components/mih_package_components/assets/images/app_icon/circle_logo.png"
|
||||
icon_size: 48 # min:48, max:256, default: 48
|
||||
|
||||
macos:
|
||||
generate: true
|
||||
image_path: "lib/mih_components/mih_package_components/assets/images/app_icon/circle_logo.png"
|
||||
|
Before Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,84 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:upgrader/upgrader.dart';
|
||||
import 'mih_config/mih_env.dart';
|
||||
import 'mih_config/mih_theme.dart';
|
||||
|
||||
class MzansiInnovationHub extends StatefulWidget {
|
||||
final GoRouter router;
|
||||
const MzansiInnovationHub({
|
||||
super.key,
|
||||
required this.router,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MzansiInnovationHub> createState() => _MzansiInnovationHubState();
|
||||
|
||||
// ignore: library_private_types_in_public_api
|
||||
static _MzansiInnovationHubState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<_MzansiInnovationHubState>();
|
||||
}
|
||||
|
||||
class _MzansiInnovationHubState extends State<MzansiInnovationHub> {
|
||||
late MihTheme theme;
|
||||
|
||||
Color getPrimany() {
|
||||
return MihColors.getPrimaryColor(theme.mode == "Dark");
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
if (AppEnviroment.getEnv() == "Dev") {
|
||||
return "Dev | MIH App: Mzansi Innovation Hub";
|
||||
} else {
|
||||
return "MIH App: Mzansi Innovation Hub";
|
||||
}
|
||||
}
|
||||
|
||||
void changeTheme(ThemeMode themeMode) {
|
||||
setState(() {
|
||||
if (themeMode == ThemeMode.light) {
|
||||
setState(() {
|
||||
theme.mode = "Light";
|
||||
});
|
||||
} else if (themeMode == ThemeMode.dark) {
|
||||
setState(() {
|
||||
theme.mode = "Dark";
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
theme.mode = "Dark";
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
theme = MihTheme();
|
||||
super.initState();
|
||||
theme.mode = "Dark";
|
||||
theme.platform = Theme.of(context).platform;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double width = MediaQuery.sizeOf(context).width;
|
||||
theme.setScreenType(width);
|
||||
precacheImage(theme.loadingImage(), context);
|
||||
return MaterialApp.router(
|
||||
title: getTitle(),
|
||||
themeMode: ThemeMode.dark,
|
||||
theme: theme.getThemeData(),
|
||||
darkTheme: theme.getThemeData(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
routerConfig: widget.router,
|
||||
builder: (context, child) {
|
||||
return UpgradeAlert(
|
||||
navigatorKey: widget.router.routerDelegate.navigatorKey,
|
||||
child: child ?? const Text('Upgrade Alert'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MIHAction extends StatefulWidget {
|
||||
final void Function()? onTap;
|
||||
final double iconSize;
|
||||
final Widget icon;
|
||||
const MIHAction({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.iconSize,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHAction> createState() => _MIHActionState();
|
||||
}
|
||||
|
||||
class _MIHActionState extends State<MIHAction> {
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
iconSize: widget.iconSize,
|
||||
padding: const EdgeInsets.all(0),
|
||||
onPressed: widget.onTap,
|
||||
icon: widget.icon,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
class MIHBody extends StatefulWidget {
|
||||
final bool borderOn;
|
||||
final List<Widget> bodyItems;
|
||||
const MIHBody({
|
||||
super.key,
|
||||
required this.borderOn,
|
||||
required this.bodyItems,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHBody> createState() => _MIHBodyState();
|
||||
}
|
||||
|
||||
class _MIHBodyState extends State<MIHBody> {
|
||||
//double paddingSize = 10;
|
||||
|
||||
double getHorizontalPaddingSize(Size screenSize) {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
if (widget.borderOn) {
|
||||
return 10;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
// mobile
|
||||
if (widget.borderOn) {
|
||||
return 10;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double getVerticalPaddingSize(Size screenSize) {
|
||||
// mobile
|
||||
if (widget.borderOn) {
|
||||
return 10;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Decoration? getBoader() {
|
||||
if (widget.borderOn) {
|
||||
return BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 3.0),
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size screenSize = MediaQuery.sizeOf(context);
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: getHorizontalPaddingSize(screenSize),
|
||||
right: getHorizontalPaddingSize(screenSize),
|
||||
bottom: getVerticalPaddingSize(screenSize),
|
||||
top: 0,
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 10,
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
top: getVerticalPaddingSize(screenSize),
|
||||
),
|
||||
width: screenSize.width,
|
||||
height: screenSize.height,
|
||||
decoration: getBoader(),
|
||||
child: ScrollConfiguration(
|
||||
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: widget.bodyItems,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MIHHeader extends StatefulWidget {
|
||||
final MainAxisAlignment headerAlignment;
|
||||
final List<Widget> headerItems;
|
||||
const MIHHeader({
|
||||
super.key,
|
||||
required this.headerAlignment,
|
||||
required this.headerItems,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHHeader> createState() => _MIHHeaderState();
|
||||
}
|
||||
|
||||
class _MIHHeaderState extends State<MIHHeader> {
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 50,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: widget.headerAlignment,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: widget.headerItems,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../mih_packages/mih_home/components/mih_app_drawer.dart';
|
||||
import 'mih_body.dart';
|
||||
import 'mih_header.dart';
|
||||
|
||||
class MIHLayoutBuilder extends StatefulWidget {
|
||||
final Widget actionButton;
|
||||
final Widget? secondaryActionButton;
|
||||
final MIHHeader header;
|
||||
final MIHBody body;
|
||||
final MIHAppDrawer? actionDrawer;
|
||||
final Widget? secondaryActionDrawer;
|
||||
final Widget? bottomNavBar;
|
||||
final bool pullDownToRefresh;
|
||||
final Future<void> Function() onPullDown;
|
||||
//final String type;
|
||||
const MIHLayoutBuilder({
|
||||
super.key,
|
||||
required this.actionButton,
|
||||
required this.header,
|
||||
required this.secondaryActionButton,
|
||||
required this.body,
|
||||
required this.actionDrawer,
|
||||
required this.secondaryActionDrawer,
|
||||
required this.bottomNavBar,
|
||||
required this.pullDownToRefresh,
|
||||
required this.onPullDown,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHLayoutBuilder> createState() => _MIHLayoutBuilderState();
|
||||
}
|
||||
|
||||
class _MIHLayoutBuilderState extends State<MIHLayoutBuilder> {
|
||||
List<Widget> getList() {
|
||||
List<Widget> temp = [];
|
||||
temp.add(widget.header);
|
||||
temp.add(widget.body);
|
||||
return temp;
|
||||
}
|
||||
|
||||
// openTheDrawer() {
|
||||
// _scaffoldKey.currentState!.openEndDrawer();
|
||||
// }
|
||||
|
||||
Widget getLayoutHeader() {
|
||||
List<Widget> temp = [];
|
||||
temp.add(widget.actionButton);
|
||||
temp.add(Flexible(child: widget.header));
|
||||
if (widget.secondaryActionButton != null) {
|
||||
temp.add(widget.secondaryActionButton!);
|
||||
} else {
|
||||
//print(widget.header.headerItems.length);
|
||||
if (widget.header.headerItems.length == 1) {
|
||||
temp.add(const SizedBox(
|
||||
width: 50,
|
||||
));
|
||||
}
|
||||
}
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: temp,
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width, double height) {
|
||||
if (widget.pullDownToRefresh == true) {
|
||||
return SafeArea(
|
||||
child: LayoutBuilder(builder: (context, BoxConstraints constraints) {
|
||||
double newheight = constraints.maxHeight;
|
||||
//print(newheight);
|
||||
return RefreshIndicator(
|
||||
onRefresh: widget.onPullDown,
|
||||
child: ListView.builder(
|
||||
itemCount: 1,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return SafeArea(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
height: newheight,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 5),
|
||||
getLayoutHeader(),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(child: widget.body),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
// child: SafeArea(
|
||||
// child: SizedBox(
|
||||
// width: width,
|
||||
// height: height,
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// children: [
|
||||
// getLayoutHeader(),
|
||||
// Expanded(child: widget.body),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
return SafeArea(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 5),
|
||||
getLayoutHeader(),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(child: widget.body),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size screenSize = MediaQuery.sizeOf(context);
|
||||
return Scaffold(
|
||||
//drawerEnableOpenDragGesture: true,
|
||||
drawer: widget.actionDrawer,
|
||||
endDrawer: widget.secondaryActionDrawer,
|
||||
body: getBody(screenSize.width, screenSize.height),
|
||||
bottomNavigationBar: widget.bottomNavBar,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_yt_video_player.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MIHTile extends StatefulWidget {
|
||||
final String tileName;
|
||||
final String? videoID;
|
||||
final Widget tileIcon;
|
||||
final void Function() onTap;
|
||||
// final Widget tileIcon;
|
||||
final Color p;
|
||||
final Color s;
|
||||
|
||||
const MIHTile({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
required this.tileName,
|
||||
this.videoID,
|
||||
required this.tileIcon,
|
||||
required this.p,
|
||||
required this.s,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHTile> createState() => _MIHTileState();
|
||||
}
|
||||
|
||||
class _MIHTileState extends State<MIHTile> {
|
||||
late Color mainC;
|
||||
late Color secondC;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
mainC = widget.p;
|
||||
secondC = widget.s;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void displayHint() {
|
||||
if (widget.videoID != null) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: widget.tileName,
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
MIHYTVideoPlayer(videoYTLink: widget.videoID!),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// print(
|
||||
// "Tile Name: ${widget.tileName}\nTitle Type: ${widget.tileIcon.runtimeType.toString()}");
|
||||
return FittedBox(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
//alignment: Alignment.center,
|
||||
width: 250,
|
||||
height: 250,
|
||||
duration: const Duration(seconds: 2),
|
||||
child: Material(
|
||||
color: mainC,
|
||||
// shadowColor:
|
||||
// MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// elevation: 5,
|
||||
borderRadius: BorderRadius.circular(80),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(80),
|
||||
// ho
|
||||
onTap: widget.onTap,
|
||||
onLongPress: () {
|
||||
displayHint();
|
||||
},
|
||||
// hoverDuration: ,
|
||||
splashColor: MihColors.getHighlightColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
highlightColor: MihColors.getHighlightColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: widget.tileIcon,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: 300,
|
||||
child: Text(
|
||||
widget.tileName,
|
||||
textAlign: TextAlign.center,
|
||||
softWrap: true,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 40.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/Example/package_tools/package_tool_two.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class PackageTest extends StatefulWidget {
|
||||
// final AppUser user;
|
||||
// final Business business;
|
||||
final TestArguments arguments;
|
||||
const PackageTest({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
// required this.user,
|
||||
// required this.business,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PackageTest> createState() => _PackageTestState();
|
||||
}
|
||||
|
||||
class _PackageTestState extends State<PackageTest> {
|
||||
int _selcetedIndex = 0;
|
||||
|
||||
MihPackageAction getAction() {
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: true,
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
// Navigator.of(context).pop();
|
||||
// Navigator.of(context).popAndPushNamed(
|
||||
// '/',
|
||||
// arguments: AuthArguments(true, false),
|
||||
// );
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = Map();
|
||||
temp[const Icon(Icons.inbox)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
};
|
||||
temp[const Icon(Icons.outbond)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 1;
|
||||
});
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
);
|
||||
}
|
||||
|
||||
void showAlert() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageAlert(
|
||||
alertIcon: Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: 100,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
alertTitle: "Oops! Looks like some fields are missing.",
|
||||
alertBody: Column(
|
||||
children: [
|
||||
Text(
|
||||
"We noticed that some required fields are still empty. To ensure your request is processed smoothly, please fill out all the highlighted fields before submitting the form again.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Here's a quick tip: ",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"))),
|
||||
const TextSpan(text: "Look for fields with an asterisk ("),
|
||||
TextSpan(
|
||||
text: "*",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"))),
|
||||
const TextSpan(
|
||||
text: ") next to them, as these are mandatory."),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
alertColour: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
PackageToolOne(
|
||||
user: widget.arguments.user,
|
||||
business: widget.arguments.business,
|
||||
),
|
||||
const PackageToolTwo(),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Tool One",
|
||||
"Tool Two",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
print("Index: $_selcetedIndex");
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class TestPackageTile extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final Business? business;
|
||||
final double packageSize;
|
||||
const TestPackageTile({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.business,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TestPackageTile> createState() => _TestPackageTileState();
|
||||
}
|
||||
|
||||
class _TestPackageTileState extends State<TestPackageTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'testPackage',
|
||||
extra: TestArguments(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
),
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/package-dev',
|
||||
// arguments: TestArguments(
|
||||
// widget.signedInUser,
|
||||
// widget.business,
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
appName: "Test",
|
||||
appIcon: Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
primaryColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 41 KiB |
@@ -1,75 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
|
||||
class MihBannerAd extends StatefulWidget {
|
||||
const MihBannerAd({super.key});
|
||||
|
||||
@override
|
||||
State<MihBannerAd> createState() => _MihBannerAdState();
|
||||
}
|
||||
|
||||
class _MihBannerAdState extends State<MihBannerAd> {
|
||||
BannerAd? _bannerAd;
|
||||
bool _isBannerAdLoaded = false;
|
||||
final adUnitId = AppEnviroment.bannerAdUnitId;
|
||||
String errorMessage = '';
|
||||
|
||||
void _loadBannerAd() {
|
||||
_bannerAd = BannerAd(
|
||||
adUnitId: adUnitId,
|
||||
request: const AdRequest(),
|
||||
size: AdSize.banner,
|
||||
listener: BannerAdListener(
|
||||
onAdLoaded: (ad) {
|
||||
debugPrint('$ad loaded.');
|
||||
setState(() {
|
||||
_isBannerAdLoaded = true;
|
||||
});
|
||||
},
|
||||
onAdFailedToLoad: (ad, err) {
|
||||
debugPrint('BannerAd failed to load: $err');
|
||||
setState(() {
|
||||
errorMessage =
|
||||
'Failed to load ad- Message: ${err.message} Code :${err.code}';
|
||||
});
|
||||
ad.dispose(); // Dispose the ad to free resources
|
||||
},
|
||||
onAdOpened: (Ad ad) => debugPrint('$ad opened.'),
|
||||
onAdClosed: (Ad ad) => debugPrint('$ad closed.'),
|
||||
onAdImpression: (Ad ad) => debugPrint('$ad impression.'),
|
||||
),
|
||||
);
|
||||
|
||||
_bannerAd!.load();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bannerAd?.dispose(); // Dispose the ad when the widget is removed
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadBannerAd();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
_bannerAd != null && _isBannerAdLoaded
|
||||
? SizedBox(
|
||||
width: _bannerAd!.size.width.toDouble(),
|
||||
height: _bannerAd!.size.height.toDouble(),
|
||||
child: AdWidget(ad: _bannerAd!))
|
||||
: SizedBox(
|
||||
child:
|
||||
Text(AppEnviroment.getEnv() == "Dev" ? errorMessage : ""),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||
|
||||
class MihBusinessProfilePreview extends StatefulWidget {
|
||||
final Business business;
|
||||
final String? myLocation;
|
||||
const MihBusinessProfilePreview({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.myLocation,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihBusinessProfilePreview> createState() =>
|
||||
_MihBusinessProfilePreviewState();
|
||||
}
|
||||
|
||||
class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
||||
late Future<String> futureImageUrl;
|
||||
PlatformFile? file;
|
||||
|
||||
String calculateDistance() {
|
||||
try {
|
||||
double distanceInKm = MIHLocationAPI().getDistanceInMeaters(
|
||||
widget.myLocation!, widget.business.gps_location) /
|
||||
1000;
|
||||
return "${distanceInKm.toStringAsFixed(2)} km";
|
||||
} catch (error) {
|
||||
print(error);
|
||||
return "*.** km";
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
futureImageUrl =
|
||||
MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double profilePictureWidth = 60;
|
||||
return Row(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}),
|
||||
const SizedBox(width: 15),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.business.Name,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.business.type,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.myLocation != null || widget.myLocation!.isEmpty
|
||||
? calculateDistance()
|
||||
: "0.00 km",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihButton extends StatelessWidget {
|
||||
final void Function()? onPressed;
|
||||
final Color buttonColor;
|
||||
final double? width;
|
||||
final double? height;
|
||||
final double? borderRadius;
|
||||
final double? elevation; // 0 = flat, higher = more shadow
|
||||
final Widget child;
|
||||
|
||||
const MihButton({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.buttonColor,
|
||||
this.width,
|
||||
this.height,
|
||||
this.borderRadius,
|
||||
this.elevation,
|
||||
required this.child,
|
||||
});
|
||||
Color _darkerColor(Color color, [double amount = .1]) {
|
||||
final hsl = HSLColor.fromColor(color);
|
||||
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
|
||||
return hslDark.toColor();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color effectiveButtonColor = onPressed == null
|
||||
? buttonColor.withValues(alpha: 0.6) // Example disabled color
|
||||
: buttonColor;
|
||||
final Color rippleColor = _darkerColor(effectiveButtonColor, 0.1);
|
||||
final double radius = borderRadius ?? 25.0;
|
||||
final double effectiveElevation =
|
||||
onPressed == null ? 0.0 : (elevation ?? 4.0);
|
||||
return MouseRegion(
|
||||
cursor: onPressed == null
|
||||
? SystemMouseCursors.basic
|
||||
: SystemMouseCursors.click,
|
||||
child: Material(
|
||||
color: effectiveButtonColor,
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
elevation: effectiveElevation,
|
||||
shadowColor: Colors.black,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
splashColor: rippleColor,
|
||||
highlightColor: rippleColor.withValues(alpha: 0.2),
|
||||
hoverColor: rippleColor.withValues(alpha: 0.3),
|
||||
onTap: onPressed,
|
||||
child: Container(
|
||||
width: width,
|
||||
height: height,
|
||||
padding: (width == null || height == null)
|
||||
? const EdgeInsets.symmetric(horizontal: 24, vertical: 12)
|
||||
: null,
|
||||
alignment: Alignment.center,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihCircleAvatar extends StatefulWidget {
|
||||
final ImageProvider<Object>? imageFile;
|
||||
final double width;
|
||||
final bool editable;
|
||||
final TextEditingController fileNameController;
|
||||
final onChange;
|
||||
final PlatformFile? userSelectedfile;
|
||||
final Color frameColor;
|
||||
final Color? backgroundColor;
|
||||
const MihCircleAvatar({
|
||||
super.key,
|
||||
required this.imageFile,
|
||||
required this.width,
|
||||
required this.editable,
|
||||
required this.fileNameController,
|
||||
required this.userSelectedfile,
|
||||
required this.frameColor,
|
||||
required this.backgroundColor,
|
||||
required this.onChange,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihCircleAvatar> createState() => _MihCircleAvatarState();
|
||||
}
|
||||
|
||||
class _MihCircleAvatarState extends State<MihCircleAvatar> {
|
||||
late ImageProvider<Object>? imagePreview;
|
||||
|
||||
ImageProvider<Object>? getAvatar() {
|
||||
// Color dark = const Color(0XFF3A4454);
|
||||
if (widget.imageFile == null) {
|
||||
return null;
|
||||
// if (widget.backgroundColor == dark) {
|
||||
// print("here in light icon");
|
||||
// return const AssetImage(
|
||||
// 'lib/mih_components/mih_package_components/assets/images/i-dont-know-light.png');
|
||||
// } else {
|
||||
// print("here in dark icon");
|
||||
// return const AssetImage(
|
||||
// 'lib/mih_components/mih_package_components/assets/images/i-dont-know-dark.png');
|
||||
// }
|
||||
} else {
|
||||
return widget.imageFile;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
setState(() {
|
||||
imagePreview = getAvatar();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
// color: Colors.white,
|
||||
alignment: Alignment.center,
|
||||
width: widget.width,
|
||||
height: widget.width,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: imagePreview != null,
|
||||
child: Positioned(
|
||||
right: widget.width * 0.03,
|
||||
child: CircleAvatar(
|
||||
radius: widget.width / 2.2,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
backgroundImage: imagePreview,
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: imagePreview != null,
|
||||
child: Icon(
|
||||
size: widget.width,
|
||||
MihIcons.mihRing,
|
||||
color: widget.frameColor,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: imagePreview == null,
|
||||
child: Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: widget.width,
|
||||
color: widget.frameColor,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.editable,
|
||||
child: Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: IconButton.filled(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
try {
|
||||
FilePickerResult? result =
|
||||
await FilePicker.platform.pickFiles(
|
||||
type: FileType.image,
|
||||
);
|
||||
// print("Here 1");
|
||||
if (MzansiInnovationHub.of(context)!.theme.getPlatform() ==
|
||||
"Web") {
|
||||
// print("Here 2");
|
||||
if (result == null) return;
|
||||
// print("Here 3");
|
||||
PlatformFile? selectedFile = result.files.first;
|
||||
setState(() {
|
||||
// print("Here 4");
|
||||
widget.onChange(selectedFile);
|
||||
// print("Here 5");
|
||||
imagePreview = MemoryImage(selectedFile.bytes!);
|
||||
});
|
||||
|
||||
setState(() {
|
||||
widget.fileNameController.text = selectedFile.name;
|
||||
});
|
||||
} else {
|
||||
if (result != null) {
|
||||
File file = File(result.files.single.path!);
|
||||
PlatformFile? androidFile = PlatformFile(
|
||||
path: file.path,
|
||||
name: file.path.split('/').last,
|
||||
size: file.lengthSync(),
|
||||
bytes: await file.readAsBytes(), // Read file bytes
|
||||
//extension: fileExtension,
|
||||
);
|
||||
setState(() {
|
||||
widget.onChange(androidFile);
|
||||
imagePreview = FileImage(file);
|
||||
});
|
||||
|
||||
setState(() {
|
||||
widget.fileNameController.text =
|
||||
file.path.split('/').last;
|
||||
});
|
||||
} else {
|
||||
print("here in else");
|
||||
// User canceled the picker
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error: $e");
|
||||
}
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.edit,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihDateField extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final String labelText;
|
||||
final bool required;
|
||||
final double? width;
|
||||
final double? height;
|
||||
final double? borderRadius;
|
||||
final double? elevation;
|
||||
final FormFieldValidator<String>? validator;
|
||||
const MihDateField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.labelText,
|
||||
required this.required,
|
||||
this.width,
|
||||
this.height,
|
||||
this.borderRadius,
|
||||
this.elevation,
|
||||
this.validator,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihDateField> createState() => _MihDateFieldState();
|
||||
}
|
||||
|
||||
class _MihDateFieldState extends State<MihDateField> {
|
||||
FormFieldState<String>? _formFieldState;
|
||||
|
||||
Future<void> _selectDate(BuildContext context) async {
|
||||
DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: widget.controller.text.isNotEmpty
|
||||
? DateTime.tryParse(widget.controller.text) ?? DateTime.now()
|
||||
: DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2100),
|
||||
);
|
||||
if (picked != null) {
|
||||
widget.controller.text = picked.toString().split(" ")[0];
|
||||
_formFieldState?.didChange(widget.controller.text);
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.labelText,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (!widget.required)
|
||||
Text(
|
||||
"(Optional)",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
FormField<String>(
|
||||
initialValue: widget.controller.text,
|
||||
validator: widget.validator,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
builder: (field) {
|
||||
_formFieldState = field;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Material(
|
||||
elevation: widget.elevation ?? 4.0,
|
||||
borderRadius:
|
||||
BorderRadius.circular(widget.borderRadius ?? 8.0),
|
||||
child: TextFormField(
|
||||
controller: widget.controller,
|
||||
readOnly: true,
|
||||
onTap: () => _selectDate(context),
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: Icon(
|
||||
Icons.calendar_today,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
errorStyle: const TextStyle(height: 0, fontSize: 0),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0, vertical: 8.0),
|
||||
filled: true,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: field.hasError
|
||||
? BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 2.0,
|
||||
)
|
||||
: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: field.hasError
|
||||
? MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark")
|
||||
: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
field.didChange(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (field.hasError)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 4.0),
|
||||
child: Text(
|
||||
field.errorText ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihDropdownField extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final String hintText;
|
||||
final bool requiredText;
|
||||
final List<String> dropdownOptions;
|
||||
final bool editable;
|
||||
final bool enableSearch;
|
||||
final FormFieldValidator<String>? validator;
|
||||
|
||||
const MihDropdownField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hintText,
|
||||
required this.dropdownOptions,
|
||||
required this.requiredText,
|
||||
required this.editable,
|
||||
required this.enableSearch,
|
||||
this.validator,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihDropdownField> createState() => _MihDropdownFieldState();
|
||||
}
|
||||
|
||||
class _MihDropdownFieldState extends State<MihDropdownField> {
|
||||
late List<DropdownMenuEntry<String>> menu;
|
||||
|
||||
List<DropdownMenuEntry<String>> buildMenuOptions(List<String> options) {
|
||||
List<DropdownMenuEntry<String>> menuList = [];
|
||||
for (final i in options) {
|
||||
menuList.add(DropdownMenuEntry(
|
||||
value: i,
|
||||
label: i,
|
||||
style: ButtonStyle(
|
||||
foregroundColor: WidgetStatePropertyAll(MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
),
|
||||
));
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
menu = buildMenuOptions(widget.dropdownOptions);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
menu = widget.dropdownOptions
|
||||
.map((e) => DropdownMenuEntry(value: e, label: e))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.hintText,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (!widget.requiredText)
|
||||
Text(
|
||||
"(Optional)",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
FormField<String>(
|
||||
validator: widget.validator,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
initialValue: widget.controller.text,
|
||||
builder: (field) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
textSelectionTheme: TextSelectionThemeData(
|
||||
cursorColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
selectionColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")
|
||||
.withValues(alpha: 0.3),
|
||||
selectionHandleColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
child: DropdownMenu(
|
||||
controller: widget.controller,
|
||||
dropdownMenuEntries: menu,
|
||||
enableSearch: widget.enableSearch,
|
||||
enableFilter: widget.enableSearch,
|
||||
enabled: widget.editable,
|
||||
textInputAction: TextInputAction.search,
|
||||
requestFocusOnTap: true,
|
||||
menuHeight: 400,
|
||||
expandedInsets: EdgeInsets.zero,
|
||||
textStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
trailingIcon: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
selectedTrailingIcon: Icon(
|
||||
Icons.arrow_drop_up,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
leadingIcon: IconButton(
|
||||
onPressed: () {
|
||||
widget.controller.clear();
|
||||
field.didChange('');
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.delete_outline_rounded,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
onSelected: (String? selectedValue) {
|
||||
field.didChange(selectedValue);
|
||||
},
|
||||
menuStyle: MenuStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(
|
||||
MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
side: WidgetStatePropertyAll(
|
||||
BorderSide(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 1.0),
|
||||
),
|
||||
shape: WidgetStatePropertyAll(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
10), // Increase for more roundness
|
||||
),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
errorStyle: const TextStyle(height: 0, fontSize: 0),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0, vertical: 8.0),
|
||||
filled: true,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
borderSide: BorderSide(
|
||||
color: field.hasError
|
||||
? MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")
|
||||
: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (field.hasError)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 4.0),
|
||||
child: Text(
|
||||
field.errorText ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihFloatingMenu extends StatefulWidget {
|
||||
final IconData? icon;
|
||||
final double? iconSize;
|
||||
final AnimatedIconData? animatedIcon;
|
||||
final SpeedDialDirection? direction;
|
||||
final List<SpeedDialChild> children;
|
||||
const MihFloatingMenu({
|
||||
super.key,
|
||||
this.icon,
|
||||
this.iconSize,
|
||||
this.animatedIcon,
|
||||
this.direction,
|
||||
required this.children,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihFloatingMenu> createState() => _MihFloatingMenuState();
|
||||
}
|
||||
|
||||
class _MihFloatingMenuState extends State<MihFloatingMenu> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SpeedDial(
|
||||
icon: widget.icon,
|
||||
buttonSize: Size(widget.iconSize ?? 56.0, widget.iconSize ?? 56.0),
|
||||
animatedIcon: widget.animatedIcon,
|
||||
direction: widget.direction ?? SpeedDialDirection.up,
|
||||
activeIcon: Icons.close,
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
activeBackgroundColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
foregroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
overlayColor: Colors.black,
|
||||
overlayOpacity: 0.5,
|
||||
children: widget.children,
|
||||
onOpen: () => debugPrint('OPENING DIAL'),
|
||||
onClose: () => debugPrint('DIAL CLOSED'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihForm extends StatefulWidget {
|
||||
final GlobalKey<FormState> formKey;
|
||||
final List<Widget> formFields;
|
||||
const MihForm({
|
||||
super.key,
|
||||
required this.formKey,
|
||||
required this.formFields,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihForm> createState() => _MihFormState();
|
||||
}
|
||||
|
||||
class _MihFormState extends State<MihForm> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Form(
|
||||
key: widget.formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: widget.formFields,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import 'package:flutter/widgets.dart'; // You need this import for IconData
|
||||
|
||||
class MihIcons {
|
||||
MihIcons._(); // This makes the class non-instantiable (good practice for utility classes)
|
||||
|
||||
// This MUST match the 'family' name you specify in pubspec.yaml
|
||||
static const _mihFontFam = 'MihIcons';
|
||||
// Set to your package name ONLY if this font is part of a separate package you created
|
||||
static const String? _mihFontPkg = null;
|
||||
|
||||
// IconData constants based on your style.css file
|
||||
// Note: We convert the hex code from CSS (\eXXX) to an integer (0xeXXX)
|
||||
|
||||
static const IconData mzansiDirectory =
|
||||
IconData(0xe900, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData personalProfile =
|
||||
IconData(0xe901, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData aboutMih =
|
||||
IconData(0xe902, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData accessControl =
|
||||
IconData(0xe903, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData businessProfile =
|
||||
IconData(0xe904, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData businessSetup =
|
||||
IconData(0xe905, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData iDontKnow =
|
||||
IconData(0xe906, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData mihLogo =
|
||||
IconData(0xe907, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData mihRing =
|
||||
IconData(0xe908, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData mzansiAi =
|
||||
IconData(0xe909, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData mzansiWallet =
|
||||
IconData(0xe90a, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData notifications =
|
||||
IconData(0xe90b, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData patientManager =
|
||||
IconData(0xe90c, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData patientProfile =
|
||||
IconData(0xe90d, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData profileSetup =
|
||||
IconData(0xe90e, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData calculator =
|
||||
IconData(0xe940, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
|
||||
static const IconData calendar =
|
||||
IconData(0xe953, fontFamily: _mihFontFam, fontPackage: _mihFontPkg);
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
|
||||
class MihNumericStepper extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final Color fillColor;
|
||||
final Color inputColor;
|
||||
final String hintText;
|
||||
final bool requiredText;
|
||||
final double? width;
|
||||
final int? minValue;
|
||||
final int? maxValue;
|
||||
final bool validationOn;
|
||||
const MihNumericStepper({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.fillColor,
|
||||
required this.inputColor,
|
||||
required this.hintText,
|
||||
required this.requiredText,
|
||||
this.width,
|
||||
this.minValue,
|
||||
this.maxValue,
|
||||
required this.validationOn,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihNumericStepper> createState() => _MihNumericStepperState();
|
||||
}
|
||||
|
||||
class _MihNumericStepperState extends State<MihNumericStepper> {
|
||||
late int _currentValue;
|
||||
late bool error;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.controller.removeListener(_syncCurrentValue);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_currentValue =
|
||||
int.tryParse(widget.controller.text) ?? widget.minValue ?? 0;
|
||||
widget.controller.text = _currentValue.toString();
|
||||
int.tryParse(widget.controller.text) ?? widget.minValue ?? 0;
|
||||
widget.controller.addListener(_syncCurrentValue);
|
||||
// print("Current Value: $_currentValue");
|
||||
}
|
||||
|
||||
void _syncCurrentValue() {
|
||||
final newValue =
|
||||
int.tryParse(widget.controller.text) ?? widget.minValue ?? 0;
|
||||
if (newValue != _currentValue) {
|
||||
setState(() {
|
||||
_currentValue = newValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
widget.hintText,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: widget.fillColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
// color: Colors.white,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(
|
||||
25), // Optional: rounds the corners
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color.fromARGB(60, 0, 0,
|
||||
0), // 0.2 opacity = 51 in alpha (255 * 0.2)
|
||||
spreadRadius: -2,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 2.0,
|
||||
left: 5.0,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 40,
|
||||
child: IconButton.filled(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
),
|
||||
color: widget.inputColor,
|
||||
iconSize: 20,
|
||||
onPressed: () {
|
||||
print("Current Value: $_currentValue");
|
||||
if (_currentValue >= (widget.minValue ?? 0)) {
|
||||
setState(() {
|
||||
widget.controller.text =
|
||||
(_currentValue - 1).toString();
|
||||
_currentValue =
|
||||
int.tryParse(widget.controller.text)!;
|
||||
});
|
||||
}
|
||||
print("New Current Value: $_currentValue");
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: _currentValue < (widget.minValue ?? 0) ||
|
||||
(widget.maxValue != null &&
|
||||
_currentValue > widget.maxValue!),
|
||||
child: const SizedBox(
|
||||
height: 21,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
Expanded(
|
||||
child: MihTextFormField(
|
||||
width: widget.width,
|
||||
fillColor: widget.fillColor,
|
||||
inputColor: widget.inputColor,
|
||||
controller: widget.controller,
|
||||
hintText: null,
|
||||
requiredText: widget.requiredText,
|
||||
readOnly: true,
|
||||
numberMode: true,
|
||||
textIputAlignment: TextAlign.center,
|
||||
validator: (value) {
|
||||
if (widget.validationOn) {
|
||||
return MihValidationServices().validateNumber(
|
||||
value, widget.minValue, widget.maxValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
// color: Colors.white,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(
|
||||
25), // Optional: rounds the corners
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color.fromARGB(60, 0, 0,
|
||||
0), // 0.2 opacity = 51 in alpha (255 * 0.2)
|
||||
spreadRadius: -2,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 2.0,
|
||||
left: 5.0,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 40,
|
||||
child: IconButton.filled(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
),
|
||||
color: widget.inputColor,
|
||||
iconSize: 20,
|
||||
onPressed: () {
|
||||
print("Current Value: $_currentValue");
|
||||
if (widget.maxValue == null ||
|
||||
_currentValue <= widget.maxValue!) {
|
||||
setState(() {
|
||||
widget.controller.text =
|
||||
(_currentValue + 1).toString();
|
||||
_currentValue =
|
||||
int.tryParse(widget.controller.text)!;
|
||||
});
|
||||
}
|
||||
print("New Current Value: $_currentValue");
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: _currentValue < (widget.minValue ?? 0) ||
|
||||
(widget.maxValue != null &&
|
||||
_currentValue > widget.maxValue!),
|
||||
child: const SizedBox(
|
||||
height: 21,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_scack_bar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mih_home/components/mih_app_drawer.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MihPackage extends StatefulWidget {
|
||||
final Widget appActionButton;
|
||||
final MihPackageTools appTools;
|
||||
final List<Widget> appBody;
|
||||
final List<String>? appToolTitles;
|
||||
final MIHAppDrawer? actionDrawer;
|
||||
int selectedbodyIndex;
|
||||
final Function(int) onIndexChange;
|
||||
MihPackage({
|
||||
super.key,
|
||||
required this.appActionButton,
|
||||
required this.appTools,
|
||||
required this.appBody,
|
||||
this.appToolTitles,
|
||||
this.actionDrawer,
|
||||
required this.selectedbodyIndex,
|
||||
required this.onIndexChange,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPackage> createState() => _MihPackageState();
|
||||
}
|
||||
|
||||
class _MihPackageState extends State<MihPackage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late PageController _pageController;
|
||||
late AnimationController _animationController;
|
||||
DateTime? lastPressedAt;
|
||||
|
||||
void unfocusAll() {
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
|
||||
Future<void> _peakAnimation() async {
|
||||
int currentPage = widget.selectedbodyIndex;
|
||||
double peakOffset = _pageController.position.viewportDimension * 0.075;
|
||||
double currentOffset =
|
||||
_pageController.page! * _pageController.position.viewportDimension;
|
||||
int nextPage =
|
||||
currentPage + 1 < widget.appBody.length ? currentPage + 1 : currentPage;
|
||||
if (nextPage != currentPage) {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
await _pageController.animateTo(
|
||||
currentOffset + peakOffset,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
// await Future.delayed(const Duration(milliseconds: 100));
|
||||
await _pageController.animateTo(
|
||||
currentPage * _pageController.position.viewportDimension,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeIn,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_pageController.dispose();
|
||||
_animationController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant MihPackage oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.selectedbodyIndex != widget.selectedbodyIndex) {
|
||||
_pageController.animateToPage(
|
||||
widget.selectedbodyIndex,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_pageController = PageController(initialPage: widget.selectedbodyIndex);
|
||||
_animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 400),
|
||||
);
|
||||
// if (!MzansiInnovationHub.of(context)!.theme.kIsWeb) {
|
||||
// // Trigger the peak animation on start (or call this elsewhere)
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// _peakAnimation();
|
||||
// });
|
||||
// }
|
||||
if (!MzansiInnovationHub.of(context)!.theme.kIsWeb) {
|
||||
// Trigger the peak animation only AFTER the route transition is complete
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final ModalRoute? currentRoute = ModalRoute.of(context);
|
||||
if (currentRoute != null) {
|
||||
currentRoute.animation?.addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed && mounted) {
|
||||
// Ensure the widget is still mounted and the animation is completed
|
||||
_peakAnimation();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size screenSize = MediaQuery.of(context).size;
|
||||
return GestureDetector(
|
||||
onTap: unfocusAll,
|
||||
child: PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (bool didPop, Object? result) {
|
||||
if (GoRouterState.of(context).name == 'mihHome' ||
|
||||
GoRouterState.of(context).name == 'mihAuthentication') {
|
||||
if (lastPressedAt == null ||
|
||||
DateTime.now().difference(lastPressedAt!) >
|
||||
const Duration(seconds: 2)) {
|
||||
// First press: show a message and update the timestamp.
|
||||
lastPressedAt = DateTime.now();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
MihSnackBar(
|
||||
child: Text("Press back again to exit"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// Second press within 2 seconds: exit the app.
|
||||
KenLogger.warning('Exiting app...'); // Your custom logger
|
||||
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
|
||||
}
|
||||
} else {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: true,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
drawer: widget.actionDrawer,
|
||||
body: SafeArea(
|
||||
bottom: false,
|
||||
minimum: EdgeInsets.only(bottom: 0),
|
||||
child: Container(
|
||||
width: screenSize.width,
|
||||
height: screenSize.height,
|
||||
//color: Colors.black,
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
widget.appActionButton,
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
// alignment: Alignment.center,
|
||||
// alignment: Alignment.centerRight,
|
||||
alignment: Alignment.centerLeft,
|
||||
// color: Colors.black,
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
widget.appToolTitles != null
|
||||
? widget
|
||||
.appToolTitles![widget.selectedbodyIndex]
|
||||
: "",
|
||||
style: const TextStyle(
|
||||
fontSize: 23,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
widget.appTools,
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: PageView.builder(
|
||||
controller: _pageController,
|
||||
itemCount: widget.appBody.length,
|
||||
itemBuilder: (context, index) {
|
||||
return widget.appBody[index];
|
||||
},
|
||||
onPageChanged: (index) {
|
||||
setState(() {
|
||||
widget.selectedbodyIndex = index;
|
||||
widget.onIndexChange(widget.selectedbodyIndex);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihPackageAction extends StatefulWidget {
|
||||
final void Function()? onTap;
|
||||
final double iconSize;
|
||||
final Widget icon;
|
||||
const MihPackageAction({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.iconSize,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPackageAction> createState() => _MihPackageActionState();
|
||||
}
|
||||
|
||||
class _MihPackageActionState extends State<MihPackageAction> {
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
iconSize: widget.iconSize,
|
||||
padding: const EdgeInsets.all(0),
|
||||
onPressed: widget.onTap,
|
||||
icon: widget.icon,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihPackageAlert extends StatefulWidget {
|
||||
final Widget alertIcon;
|
||||
final String alertTitle;
|
||||
final Widget alertBody;
|
||||
final Color alertColour;
|
||||
const MihPackageAlert({
|
||||
super.key,
|
||||
required this.alertIcon,
|
||||
required this.alertTitle,
|
||||
required this.alertBody,
|
||||
required this.alertColour,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPackageAlert> createState() => _MihPackageAlertState();
|
||||
}
|
||||
|
||||
class _MihPackageAlertState extends State<MihPackageAlert> {
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
late double popUpTitleSize;
|
||||
late double popUpSubtitleSize;
|
||||
late double popUpBodySize;
|
||||
late double popUpIconSize;
|
||||
late double popUpPaddingSize;
|
||||
Size? size;
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = (size!.width / 4) * 2;
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 25.0;
|
||||
popUpSubtitleSize = 20.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 25.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = size!.width - (size!.width * 0.1);
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 20.0;
|
||||
popUpSubtitleSize = 18.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 15.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
size = MediaQuery.of(context).size;
|
||||
checkScreenSize();
|
||||
return Dialog(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(color: widget.alertColour, width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
widget.alertIcon,
|
||||
//const SizedBox(height: 5),
|
||||
Text(
|
||||
widget.alertTitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: widget.alertColour,
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
widget.alertBody,
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,234 +0,0 @@
|
||||
import 'package:app_settings/app_settings.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_yt_video_player.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihPackageTile extends StatefulWidget {
|
||||
final String appName;
|
||||
final String? ytVideoID;
|
||||
final Widget appIcon;
|
||||
final void Function() onTap;
|
||||
final double iconSize;
|
||||
final Color primaryColor;
|
||||
final Color secondaryColor;
|
||||
final bool? authenticateUser;
|
||||
const MihPackageTile({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
required this.appName,
|
||||
this.ytVideoID,
|
||||
required this.appIcon,
|
||||
required this.iconSize,
|
||||
required this.primaryColor,
|
||||
required this.secondaryColor,
|
||||
this.authenticateUser,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPackageTile> createState() => _MihPackageTileState();
|
||||
}
|
||||
|
||||
class _MihPackageTileState extends State<MihPackageTile> {
|
||||
final LocalAuthentication _auth = LocalAuthentication();
|
||||
|
||||
void displayHint() {
|
||||
if (widget.ytVideoID != null) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: widget.appName,
|
||||
// windowTools: const [],
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: MIHYTVideoPlayer(
|
||||
videoYTLink: widget.ytVideoID!,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> isUserAuthenticated() async {
|
||||
final bool canAuthWithBio = await _auth.canCheckBiometrics;
|
||||
final bool canAuthenticate =
|
||||
canAuthWithBio || await _auth.isDeviceSupported();
|
||||
print("Auth Available: $canAuthenticate");
|
||||
if (canAuthenticate) {
|
||||
try {
|
||||
final bool didBioAuth = await _auth.authenticate(
|
||||
localizedReason: "Authenticate to access ${widget.appName}",
|
||||
options: const AuthenticationOptions(
|
||||
biometricOnly: false,
|
||||
),
|
||||
);
|
||||
if (didBioAuth) {
|
||||
return true;
|
||||
} else {
|
||||
authErrorPopUp();
|
||||
}
|
||||
// print("Authenticated: $didBioAuth");
|
||||
} catch (error) {
|
||||
print("Auth Error: $error");
|
||||
authErrorPopUp();
|
||||
}
|
||||
} else {
|
||||
print("Auth Error: No Biometrics Available");
|
||||
authErrorPopUp();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void authErrorPopUp() {
|
||||
Widget alertpopUp = MihPackageAlert(
|
||||
alertIcon: Icon(
|
||||
Icons.fingerprint,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 100,
|
||||
),
|
||||
alertTitle: "Biometric Authentication Required",
|
||||
alertBody: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Hi there! To jump into the ${widget.appName} Package, you'll need to authenticate yourself with your devices biometrics, please set up biometric authentication (like fingerprint, face ID, pattern or pin) on your device first.\n\nIf you have already set up biometric authentication, press \"Authenticate now\" to try again or press \"Set Up Authentication\" to go to your device settings.",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Wrap(
|
||||
runAlignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
AppSettings.openAppSettings(
|
||||
type: AppSettingsType.security,
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
buttonColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Set Up Authentication",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
authenticateUser();
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Authenticate Now",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
alertColour: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return alertpopUp;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> authenticateUser() async {
|
||||
if (widget.authenticateUser != null &&
|
||||
widget.authenticateUser! &&
|
||||
!kIsWeb) {
|
||||
if (await isUserAuthenticated()) {
|
||||
widget.onTap();
|
||||
}
|
||||
} else {
|
||||
widget.onTap();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
// alignment: Alignment.topCenter,
|
||||
// color: Colors.black,
|
||||
// width: widget.iconSize,
|
||||
// height: widget.iconSize + widget.iconSize / 3,
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
authenticateUser();
|
||||
},
|
||||
onLongPress: null, // Do this later
|
||||
child: Column(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 3,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
double iconHeight = constraints.maxWidth;
|
||||
return Container(
|
||||
width: iconHeight,
|
||||
height: iconHeight,
|
||||
child:
|
||||
FittedBox(fit: BoxFit.fitHeight, child: widget.appIcon),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
widget.appName,
|
||||
textAlign: TextAlign.center,
|
||||
// softWrap: true,
|
||||
// overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihPackageToolBody extends StatefulWidget {
|
||||
final bool borderOn;
|
||||
final Widget bodyItem;
|
||||
final double? innerHorizontalPadding;
|
||||
const MihPackageToolBody({
|
||||
super.key,
|
||||
required this.borderOn,
|
||||
required this.bodyItem,
|
||||
this.innerHorizontalPadding,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPackageToolBody> createState() => _MihPackageToolBodyState();
|
||||
}
|
||||
|
||||
class _MihPackageToolBodyState extends State<MihPackageToolBody> {
|
||||
late double _innerBodyPadding;
|
||||
double getHorizontalPaddingSize(Size screenSize) {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
if (widget.borderOn) {
|
||||
return widget.innerHorizontalPadding ?? 10;
|
||||
} else {
|
||||
return widget.innerHorizontalPadding ?? 0;
|
||||
}
|
||||
} else {
|
||||
// mobile
|
||||
if (widget.borderOn) {
|
||||
return widget.innerHorizontalPadding ?? 10;
|
||||
} else {
|
||||
return widget.innerHorizontalPadding ?? 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double getVerticalPaddingSize(Size screenSize) {
|
||||
// mobile
|
||||
if (widget.borderOn) {
|
||||
return 10;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Decoration? getBoader() {
|
||||
if (widget.borderOn) {
|
||||
_innerBodyPadding = 10.0;
|
||||
return BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 3.0),
|
||||
);
|
||||
} else {
|
||||
_innerBodyPadding = 0.0;
|
||||
return BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 3.0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size screenSize = MediaQuery.sizeOf(context);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: getHorizontalPaddingSize(screenSize),
|
||||
right: getHorizontalPaddingSize(screenSize),
|
||||
bottom: getVerticalPaddingSize(screenSize),
|
||||
top: 0,
|
||||
),
|
||||
child: Container(
|
||||
height: screenSize.height,
|
||||
decoration: getBoader(),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(_innerBodyPadding),
|
||||
child: widget.bodyItem,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MihPackageTools extends StatefulWidget {
|
||||
final Map<Widget, void Function()?> tools;
|
||||
int selcetedIndex;
|
||||
MihPackageTools({
|
||||
super.key,
|
||||
required this.tools,
|
||||
required this.selcetedIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPackageTools> createState() => _MihPackageToolsState();
|
||||
}
|
||||
|
||||
class _MihPackageToolsState extends State<MihPackageTools> {
|
||||
List<Widget> getTools() {
|
||||
List<Widget> temp = [];
|
||||
int index = 0;
|
||||
widget.tools.forEach((icon, onTap) {
|
||||
temp.add(
|
||||
Visibility(
|
||||
visible: widget.selcetedIndex != index,
|
||||
child: IconButton(
|
||||
onPressed: onTap,
|
||||
icon: icon,
|
||||
),
|
||||
),
|
||||
);
|
||||
temp.add(
|
||||
Visibility(
|
||||
visible: widget.selcetedIndex == index,
|
||||
child: IconButton.filled(
|
||||
onPressed: onTap,
|
||||
icon: icon,
|
||||
),
|
||||
),
|
||||
);
|
||||
index += 1;
|
||||
});
|
||||
return temp;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: getTools(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihPackageWindow extends StatefulWidget {
|
||||
final String windowTitle;
|
||||
final Widget windowBody;
|
||||
final List<SpeedDialChild>? menuOptions;
|
||||
final void Function() onWindowTapClose;
|
||||
final bool fullscreen;
|
||||
const MihPackageWindow({
|
||||
super.key,
|
||||
required this.fullscreen,
|
||||
required this.windowTitle,
|
||||
this.menuOptions,
|
||||
required this.onWindowTapClose,
|
||||
required this.windowBody,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPackageWindow> createState() => _MihPackageWindowState();
|
||||
}
|
||||
|
||||
class _MihPackageWindowState extends State<MihPackageWindow> {
|
||||
late double windowTitleSize;
|
||||
late double horizontralWindowPadding;
|
||||
late double vertticalWindowPadding;
|
||||
late double windowWidth;
|
||||
late double windowHeight;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
void checkScreenSize() {
|
||||
// print("screen width: $width");
|
||||
// print("screen height: $height");
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
windowTitleSize = 25;
|
||||
horizontralWindowPadding = width / 7;
|
||||
vertticalWindowPadding = 10;
|
||||
windowWidth = width;
|
||||
windowHeight = height;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
windowTitleSize = 20;
|
||||
horizontralWindowPadding = 10;
|
||||
vertticalWindowPadding = 10;
|
||||
windowWidth = width;
|
||||
windowHeight = height;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Widget getHeader() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// color: Colors.white,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(25), // Optional: rounds the corners
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color.fromARGB(
|
||||
60, 0, 0, 0), // 0.2 opacity = 51 in alpha (255 * 0.2)
|
||||
spreadRadius: -2,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 2.0,
|
||||
left: 5.0,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 40,
|
||||
child: IconButton.filled(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(
|
||||
MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
),
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
iconSize: 20,
|
||||
onPressed: () {
|
||||
widget.onWindowTapClose();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Text(
|
||||
widget.windowTitle,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: windowTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: (widget.menuOptions?.isNotEmpty ?? false),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 2.0,
|
||||
right: 5.0,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 40,
|
||||
child: MihFloatingMenu(
|
||||
iconSize: 40,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
direction: SpeedDialDirection.down,
|
||||
children: widget.menuOptions != null ? widget.menuOptions! : [],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// If no menu, add a SizedBox to keep alignment
|
||||
if (!(widget.menuOptions?.isNotEmpty ?? false))
|
||||
const SizedBox(width: 40),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
checkScreenSize();
|
||||
return Dialog(
|
||||
insetPadding: EdgeInsets.symmetric(
|
||||
horizontal: horizontralWindowPadding,
|
||||
vertical: vertticalWindowPadding,
|
||||
),
|
||||
insetAnimationCurve: Easing.emphasizedDecelerate,
|
||||
insetAnimationDuration: Durations.short1,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: widget.fullscreen
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
getHeader(),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(child: widget.windowBody)),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
getHeader(),
|
||||
const SizedBox(height: 5),
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 25,
|
||||
right: 25,
|
||||
bottom: vertticalWindowPadding,
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: windowHeight * 0.85,
|
||||
maxWidth: windowWidth * 0.85,
|
||||
),
|
||||
child: MihSingleChildScroll(child: widget.windowBody),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
|
||||
class MihPersonalProfilePreview extends StatefulWidget {
|
||||
final AppUser user;
|
||||
const MihPersonalProfilePreview({
|
||||
super.key,
|
||||
required this.user,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPersonalProfilePreview> createState() =>
|
||||
_MihPersonalProfilePreviewState();
|
||||
}
|
||||
|
||||
class _MihPersonalProfilePreviewState extends State<MihPersonalProfilePreview> {
|
||||
late Future<String> futureImageUrl;
|
||||
// String imageUrl = "";
|
||||
PlatformFile? file;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
futureImageUrl =
|
||||
MihFileApi.getMinioFileUrl(widget.user.pro_pic_path, context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double profilePictureWidth = 60;
|
||||
return Row(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.user.username.isNotEmpty
|
||||
? widget.user.username
|
||||
: "Username",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.user.fname.isNotEmpty
|
||||
? "${widget.user.fname} ${widget.user.lname}"
|
||||
: "Name Surname",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.user.type.toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihRadioOptions extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final String hintText;
|
||||
final Color fillColor;
|
||||
final Color secondaryFillColor;
|
||||
final bool requiredText;
|
||||
final List<String> radioOptions;
|
||||
const MihRadioOptions({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hintText,
|
||||
required this.fillColor,
|
||||
required this.secondaryFillColor,
|
||||
required this.requiredText,
|
||||
required this.radioOptions,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihRadioOptions> createState() => _MihRadioOptionsState();
|
||||
}
|
||||
|
||||
class _MihRadioOptionsState extends State<MihRadioOptions> {
|
||||
// late String _currentSelection;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.controller.text.isEmpty && widget.radioOptions.isNotEmpty) {
|
||||
widget.controller.text = widget.radioOptions[0];
|
||||
}
|
||||
// else{
|
||||
// int index = widget.radioOptions
|
||||
// .indexWhere((element) => element == option);
|
||||
// _currentSelection = widget.radioOptions[index];
|
||||
// widget.controller.text = option;
|
||||
|
||||
// }
|
||||
// _currentSelection = widget.radioOptions[0];
|
||||
}
|
||||
|
||||
// The method to handle a change in selection.
|
||||
void _onChanged(String? value) {
|
||||
if (value != null) {
|
||||
widget.controller.text = value;
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayRadioOptions(String selection) {
|
||||
return Material(
|
||||
elevation: 4.0,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: widget.fillColor,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Column(
|
||||
children: widget.radioOptions.map((option) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_onChanged(option);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
option,
|
||||
style: TextStyle(
|
||||
color: widget.secondaryFillColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
),
|
||||
Radio<String>(
|
||||
value: option,
|
||||
groupValue: selection,
|
||||
onChanged: _onChanged,
|
||||
activeColor: widget.secondaryFillColor,
|
||||
fillColor: WidgetStateProperty.resolveWith<Color?>(
|
||||
(Set<WidgetState> states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return widget.secondaryFillColor; // Color when selected
|
||||
}
|
||||
return widget.secondaryFillColor;
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: widget.controller,
|
||||
builder: (context, child) {
|
||||
final currentSelection = widget.controller.text;
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.hintText,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: widget.fillColor,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !widget.requiredText,
|
||||
child: Text(
|
||||
"(Optional)",
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
color: widget.fillColor,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
displayRadioOptions(currentSelection),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
SnackBar MihSnackBar({
|
||||
required Widget child,
|
||||
}) {
|
||||
return SnackBar(
|
||||
content: child,
|
||||
shape: StadiumBorder(),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: Duration(seconds: 2),
|
||||
width: null,
|
||||
action: SnackBarAction(
|
||||
label: "Dismiss",
|
||||
onPressed: () {},
|
||||
),
|
||||
// elevation: 30,
|
||||
);
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihSearchBar extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final String hintText;
|
||||
final IconData prefixIcon;
|
||||
final IconData? prefixAltIcon;
|
||||
final List<Widget>? suffixTools;
|
||||
final double? width;
|
||||
final double? height;
|
||||
final Color fillColor;
|
||||
final Color hintColor;
|
||||
final void Function()? onPrefixIconTap;
|
||||
final void Function()? onClearIconTap;
|
||||
final double? elevation;
|
||||
final FocusNode searchFocusNode;
|
||||
|
||||
const MihSearchBar({
|
||||
Key? key,
|
||||
required this.controller,
|
||||
required this.hintText,
|
||||
required this.prefixIcon,
|
||||
this.prefixAltIcon,
|
||||
this.suffixTools,
|
||||
this.width,
|
||||
this.height,
|
||||
required this.fillColor,
|
||||
required this.hintColor,
|
||||
required this.onPrefixIconTap,
|
||||
this.onClearIconTap,
|
||||
this.elevation,
|
||||
required this.searchFocusNode,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MihSearchBar> createState() => _MihSearchBarState();
|
||||
}
|
||||
|
||||
class _MihSearchBarState extends State<MihSearchBar> {
|
||||
bool _showClearIcon = false;
|
||||
|
||||
Widget getPrefixIcon() {
|
||||
if (_showClearIcon) {
|
||||
// If the clear icon is shown and an alternative prefix icon is provided, use it
|
||||
return widget.prefixAltIcon != null
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Icon(
|
||||
widget.prefixAltIcon,
|
||||
color: widget.hintColor,
|
||||
size: 35,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Icon(
|
||||
Icons.search,
|
||||
color: widget.hintColor,
|
||||
size: 35,
|
||||
),
|
||||
); // Default to search icon if no alt icon
|
||||
} else {
|
||||
// Return the primary prefix icon or the alternative if provided
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Icon(
|
||||
Icons.search,
|
||||
color: widget.hintColor,
|
||||
size: 35,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 1. Add the listener to the controller
|
||||
widget.controller.addListener(_updateClearIconVisibility);
|
||||
// 2. Initialize the clear icon visibility based on the current text
|
||||
_updateClearIconVisibility();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.controller.removeListener(_updateClearIconVisibility);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _updateClearIconVisibility() {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
final bool shouldShow = widget.controller.text.isNotEmpty;
|
||||
// Only call setState if the visibility state actually changes
|
||||
if (_showClearIcon != shouldShow) {
|
||||
setState(() {
|
||||
_showClearIcon = shouldShow;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
elevation: widget.elevation ?? 4.0, // Use provided elevation or default
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
color: widget.fillColor,
|
||||
child: AnimatedContainer(
|
||||
// Keep AnimatedContainer for width/height transitions
|
||||
alignment: Alignment.centerLeft,
|
||||
width: widget.width,
|
||||
height: widget.height ?? 50,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
),
|
||||
child: Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
textSelectionTheme: TextSelectionThemeData(
|
||||
selectionColor: widget.hintColor.withValues(alpha: 0.3),
|
||||
selectionHandleColor: widget.hintColor,
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
controller: widget.controller, // Assign the controller
|
||||
focusNode: widget.searchFocusNode,
|
||||
autocorrect: true,
|
||||
spellCheckConfiguration: kIsWeb ? null : SpellCheckConfiguration(),
|
||||
onSubmitted: (value) {
|
||||
widget.onPrefixIconTap
|
||||
?.call(); // Call the prefix icon tap handler
|
||||
},
|
||||
style: TextStyle(
|
||||
color: widget.hintColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
),
|
||||
cursorColor: widget.hintColor,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
hintText: widget.hintText,
|
||||
hintStyle: TextStyle(
|
||||
color: widget.hintColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 10.0, vertical: 15.0),
|
||||
prefixIcon: GestureDetector(
|
||||
onTap: widget.onPrefixIconTap,
|
||||
child: getPrefixIcon(),
|
||||
),
|
||||
suffixIcon: Row(
|
||||
// Use a Row for multiple suffix icons
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Optional suffix tools
|
||||
if (widget.suffixTools != null) ...widget.suffixTools!,
|
||||
// Clear Icon (conditionally visible)
|
||||
if (_showClearIcon) // Only show if input is not empty
|
||||
IconButton(
|
||||
iconSize: 35,
|
||||
icon: Icon(Icons.clear,
|
||||
color: widget.hintColor), // Clear icon
|
||||
onPressed: widget.onClearIconTap ??
|
||||
() {
|
||||
widget.controller.clear();
|
||||
// No need for setState here, _updateClearIconVisibility will handle it
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihSingleChildScroll extends StatefulWidget {
|
||||
final Widget child;
|
||||
const MihSingleChildScroll({
|
||||
super.key,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihSingleChildScroll> createState() => _MihSingleChildScrollState();
|
||||
}
|
||||
|
||||
class _MihSingleChildScrollState extends State<MihSingleChildScroll> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
bottom: false,
|
||||
minimum: EdgeInsets.only(bottom: 5),
|
||||
child: ScrollConfiguration(
|
||||
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
||||
child: SingleChildScrollView(
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,309 +0,0 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihTextFormField extends StatefulWidget {
|
||||
final double? width;
|
||||
final double? height;
|
||||
final Color fillColor;
|
||||
final Color inputColor;
|
||||
final TextEditingController controller;
|
||||
final bool? hasError;
|
||||
final String? hintText;
|
||||
final double? borderRadius;
|
||||
final bool? multiLineInput;
|
||||
final bool? readOnly;
|
||||
final bool? passwordMode;
|
||||
final bool? numberMode;
|
||||
final bool requiredText;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final List<String>? autofillHints;
|
||||
final double? elevation;
|
||||
final TextAlign? textIputAlignment;
|
||||
|
||||
const MihTextFormField({
|
||||
Key? key,
|
||||
this.width,
|
||||
this.height,
|
||||
required this.fillColor,
|
||||
required this.inputColor,
|
||||
required this.controller,
|
||||
this.hasError,
|
||||
required this.hintText,
|
||||
required this.requiredText,
|
||||
this.borderRadius,
|
||||
this.multiLineInput,
|
||||
this.readOnly,
|
||||
this.passwordMode,
|
||||
this.numberMode,
|
||||
this.validator,
|
||||
this.autofillHints,
|
||||
this.elevation,
|
||||
this.textIputAlignment,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MihTextFormField> createState() => _MihTextFormFieldState();
|
||||
}
|
||||
|
||||
class _MihTextFormFieldState extends State<MihTextFormField> {
|
||||
late bool _obscureText;
|
||||
FormFieldState<String>? _formFieldState;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_obscureText = widget.passwordMode ?? false;
|
||||
widget.controller.addListener(_onControllerTextChanged);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant MihTextFormField oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
// If the controller itself changes, remove listener from old and add to new
|
||||
if (widget.controller != oldWidget.controller) {
|
||||
oldWidget.controller.removeListener(_onControllerTextChanged);
|
||||
widget.controller.addListener(_onControllerTextChanged);
|
||||
// Immediately update form field state if controller changed and has value
|
||||
_formFieldState?.didChange(widget.controller.text);
|
||||
}
|
||||
}
|
||||
|
||||
void _onControllerTextChanged() {
|
||||
// Only update the FormField's value if it's not already the same
|
||||
// and if the formFieldState is available.
|
||||
if (_formFieldState != null &&
|
||||
_formFieldState!.value != widget.controller.text) {
|
||||
_formFieldState!.didChange(widget.controller.text);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.controller.removeListener(_onControllerTextChanged);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isMultiline = widget.multiLineInput == true;
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: widget.width,
|
||||
// height: widget.height,
|
||||
height: isMultiline ? null : widget.height,
|
||||
child: Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
textSelectionTheme: TextSelectionThemeData(
|
||||
selectionColor: widget.inputColor.withValues(alpha: 0.3),
|
||||
selectionHandleColor: widget.inputColor,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: widget.hintText != null,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.hintText ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: widget.fillColor,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !widget.requiredText,
|
||||
child: Text(
|
||||
"(Optional)",
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
color: widget.fillColor,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
FormField<String>(
|
||||
initialValue: widget.controller.text,
|
||||
validator: widget.validator,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
builder: (field) {
|
||||
_formFieldState = field;
|
||||
return Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start, // <-- Add this line
|
||||
children: [
|
||||
Material(
|
||||
elevation: widget.elevation ?? 4.0,
|
||||
borderRadius:
|
||||
BorderRadius.circular(widget.borderRadius ?? 8.0),
|
||||
child: SizedBox(
|
||||
height: widget.height != null
|
||||
? widget.height! - 30
|
||||
: null,
|
||||
child: TextFormField(
|
||||
controller: widget.controller,
|
||||
cursorColor: widget.inputColor,
|
||||
autofillHints: widget.autofillHints,
|
||||
autocorrect: true,
|
||||
spellCheckConfiguration: (kIsWeb ||
|
||||
widget.passwordMode == true ||
|
||||
widget.numberMode == true)
|
||||
? null
|
||||
: SpellCheckConfiguration(),
|
||||
textAlign:
|
||||
widget.textIputAlignment ?? TextAlign.start,
|
||||
textAlignVertical: widget.multiLineInput == true
|
||||
? TextAlignVertical.top
|
||||
: TextAlignVertical.center,
|
||||
obscureText: widget.passwordMode == true
|
||||
? _obscureText
|
||||
: false,
|
||||
expands: widget.passwordMode == true
|
||||
? false
|
||||
: (widget.multiLineInput ?? false),
|
||||
maxLines: widget.passwordMode == true ? 1 : null,
|
||||
readOnly: widget.readOnly ?? false,
|
||||
keyboardType: widget.numberMode == true
|
||||
? const TextInputType.numberWithOptions(
|
||||
decimal: true)
|
||||
: null,
|
||||
inputFormatters: widget.numberMode == true
|
||||
? [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'^\d*\.?\d*'))
|
||||
]
|
||||
: null,
|
||||
style: TextStyle(
|
||||
color: widget.inputColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: widget.passwordMode == true
|
||||
? IconButton(
|
||||
icon: Icon(
|
||||
_obscureText
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
color: widget.inputColor,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
},
|
||||
)
|
||||
: null,
|
||||
errorStyle: const TextStyle(
|
||||
height: 0, fontSize: 0), // <-- Add this line
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0, vertical: 8.0),
|
||||
filled: true,
|
||||
fillColor: widget.fillColor,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: field.hasError
|
||||
? BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 2.0,
|
||||
)
|
||||
: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: field.hasError
|
||||
? MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark")
|
||||
: widget.inputColor,
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
field.didChange(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
if (field.hasError)
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 8.0, top: 4.0),
|
||||
child: Text(
|
||||
field.errorText ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihTimeField extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final String labelText;
|
||||
final bool required;
|
||||
final double? width;
|
||||
final double? height;
|
||||
final double? borderRadius;
|
||||
final double? elevation;
|
||||
final FormFieldValidator<String>? validator;
|
||||
|
||||
const MihTimeField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.labelText,
|
||||
required this.required,
|
||||
this.width,
|
||||
this.height,
|
||||
this.borderRadius,
|
||||
this.elevation,
|
||||
this.validator,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihTimeField> createState() => _MihTimeFieldState();
|
||||
}
|
||||
|
||||
class _MihTimeFieldState extends State<MihTimeField> {
|
||||
FormFieldState<String>? _formFieldState;
|
||||
|
||||
Future<void> _selectTime(BuildContext context) async {
|
||||
TimeOfDay? picked = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: widget.controller.text.isNotEmpty
|
||||
? TimeOfDay(
|
||||
hour: int.tryParse(widget.controller.text.split(":")[0]) ?? 0,
|
||||
minute: int.tryParse(widget.controller.text.split(":")[1]) ?? 0,
|
||||
)
|
||||
: TimeOfDay.now(),
|
||||
builder: (context, child) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true),
|
||||
child: child as Widget,
|
||||
);
|
||||
},
|
||||
);
|
||||
if (picked != null) {
|
||||
final hours = picked.hour.toString().padLeft(2, '0');
|
||||
final minutes = picked.minute.toString().padLeft(2, '0');
|
||||
widget.controller.text = "$hours:$minutes";
|
||||
_formFieldState?.didChange(widget.controller.text);
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.labelText,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (!widget.required)
|
||||
Text(
|
||||
"(Optional)",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
FormField<String>(
|
||||
initialValue: widget.controller.text,
|
||||
validator: widget.validator,
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
builder: (field) {
|
||||
_formFieldState = field;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Material(
|
||||
elevation: widget.elevation ?? 4.0,
|
||||
borderRadius:
|
||||
BorderRadius.circular(widget.borderRadius ?? 8.0),
|
||||
child: TextFormField(
|
||||
controller: widget.controller,
|
||||
readOnly: true,
|
||||
onTap: () => _selectTime(context),
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: Icon(
|
||||
Icons.access_time,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
errorStyle: const TextStyle(height: 0, fontSize: 0),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0, vertical: 8.0),
|
||||
filled: true,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: field.hasError
|
||||
? BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 2.0,
|
||||
)
|
||||
: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: field.hasError
|
||||
? MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark")
|
||||
: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
widget.borderRadius ?? 8.0),
|
||||
borderSide: BorderSide(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 3.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
field.didChange(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (field.hasError)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, top: 4.0),
|
||||
child: Text(
|
||||
field.errorText ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihToggle extends StatefulWidget {
|
||||
final String hintText;
|
||||
final bool initialPostion;
|
||||
final Color fillColor;
|
||||
final Color secondaryFillColor;
|
||||
final bool? readOnly;
|
||||
final double? elevation;
|
||||
final void Function(bool) onChange;
|
||||
const MihToggle({
|
||||
super.key,
|
||||
required this.hintText,
|
||||
required this.initialPostion,
|
||||
required this.fillColor,
|
||||
required this.secondaryFillColor,
|
||||
this.readOnly,
|
||||
this.elevation,
|
||||
required this.onChange,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihToggle> createState() => _MihToggleState();
|
||||
}
|
||||
|
||||
class _MihToggleState extends State<MihToggle> {
|
||||
late bool togglePosition;
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant MihToggle oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.initialPostion != oldWidget.initialPostion) {
|
||||
setState(() {
|
||||
togglePosition = widget.initialPostion;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
togglePosition = widget.initialPostion;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.hintText,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: widget.fillColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
// Material(
|
||||
// elevation: widget.elevation ?? 0.01,
|
||||
// shadowColor: widget.secondaryFillColor.withOpacity(0.5),
|
||||
// color: Colors.transparent,
|
||||
// shape: StadiumBorder(),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(
|
||||
30), // Adjust the border radius to match the toggle
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.15),
|
||||
offset: Offset(
|
||||
0, widget.elevation ?? 10), // Adjust the vertical offset
|
||||
blurRadius: widget.elevation ?? 10,
|
||||
spreadRadius: 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Switch(
|
||||
value: togglePosition,
|
||||
trackOutlineColor: WidgetStateProperty.resolveWith<Color?>(
|
||||
(states) {
|
||||
if (widget.readOnly == true) {
|
||||
return Colors.grey;
|
||||
}
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"); // Outline color when active
|
||||
}
|
||||
return MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"); // Outline color when active
|
||||
},
|
||||
),
|
||||
activeColor: widget.readOnly == true
|
||||
? Colors.grey
|
||||
: widget.secondaryFillColor,
|
||||
activeTrackColor: widget.readOnly == true
|
||||
? Colors.grey.shade400
|
||||
: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inactiveThumbColor: widget.readOnly == true
|
||||
? Colors.grey
|
||||
: widget.secondaryFillColor,
|
||||
inactiveTrackColor: widget.readOnly == true
|
||||
? Colors.grey.shade400
|
||||
: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// activeColor: widget.secondaryFillColor,
|
||||
// activeTrackColor: widget.fillColor,
|
||||
// inactiveThumbColor: widget.fillColor,
|
||||
// inactiveTrackColor: widget.secondaryFillColor,
|
||||
// onChanged: widget.readOnly != true ? widget.onChange : null,
|
||||
onChanged: widget.readOnly != true
|
||||
? (newValue) {
|
||||
setState(() {
|
||||
togglePosition = newValue; // Update internal state
|
||||
});
|
||||
widget.onChange(newValue); // Call the parent's onChange
|
||||
}
|
||||
: null,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,530 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
class MIHDeleteMessage extends StatefulWidget {
|
||||
final String deleteType;
|
||||
final void Function() onTap;
|
||||
const MIHDeleteMessage({
|
||||
super.key,
|
||||
required this.deleteType,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHDeleteMessage> createState() => _MIHDeleteMessageState();
|
||||
}
|
||||
|
||||
class _MIHDeleteMessageState extends State<MIHDeleteMessage> {
|
||||
var messageTypes = <String, Widget>{};
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
late double popUpTitleSize;
|
||||
late double popUpSubtitleSize;
|
||||
late double popUpBodySize;
|
||||
late double popUpIconSize;
|
||||
late double popUpPaddingSize;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = (width / 4) * 2;
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 25.0;
|
||||
popUpSubtitleSize = 20.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 25.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = width - (width * 0.1);
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 20.0;
|
||||
popUpSubtitleSize = 18.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 15.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void setDeleteNote() {
|
||||
messageTypes["Note"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Are you sure you want to delete this?",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"This note will be deleted permanently. Are you certain you want to delete it?",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
MihButton(
|
||||
onPressed: widget.onTap,
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Delete",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setFileNote() {
|
||||
messageTypes["File"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Are you sure you want to delete this?",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"This file will be deleted permanently. Are you certain you want to delete it?",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
MihButton(
|
||||
onPressed: widget.onTap,
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Delete",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setDeleteEmployee() {
|
||||
messageTypes["Employee"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Are you sure you want to delete this?",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"This team member will be deleted permanently from the business profile. Are you certain you want to delete it?",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
MihButton(
|
||||
onPressed: widget.onTap,
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Delete",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setDeleteAppointment() {
|
||||
messageTypes["Appointment"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Are you sure you want to delete this?",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"This appointment will be deleted permanently from your calendar. Are you certain you want to delete it?",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
MihButton(
|
||||
onPressed: widget.onTap,
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Delete",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setDeleteLoyaltyCard() {
|
||||
messageTypes["Loyalty Card"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Are you sure you want to delete this?",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"This Card will be deleted permanently from your Mzansi Wallet. Are you certain you want to delete it?",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
MihButton(
|
||||
onPressed: widget.onTap,
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Delete",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget? getDeleteMessage(String type) {
|
||||
return messageTypes[type];
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
checkScreenSize();
|
||||
setDeleteNote();
|
||||
setFileNote();
|
||||
setDeleteEmployee();
|
||||
setDeleteAppointment();
|
||||
setDeleteLoyaltyCard();
|
||||
//print(size);
|
||||
// setState(() {
|
||||
// width = size.width;
|
||||
// height = size.height;
|
||||
// });
|
||||
return Dialog(child: getDeleteMessage(widget.deleteType));
|
||||
}
|
||||
}
|
||||
@@ -1,909 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
class MIHErrorMessage extends StatefulWidget {
|
||||
final String errorType;
|
||||
const MIHErrorMessage({
|
||||
super.key,
|
||||
required this.errorType,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHErrorMessage> createState() => _MIHErrorMessageState();
|
||||
}
|
||||
|
||||
class _MIHErrorMessageState extends State<MIHErrorMessage> {
|
||||
var messageTypes = <String, Widget>{};
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
late double popUpTitleSize;
|
||||
late double popUpSubtitleSize;
|
||||
late double popUpBodySize;
|
||||
late double popUpIconSize;
|
||||
late double popUpPaddingSize;
|
||||
Size? size;
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = (size!.width / 4) * 2;
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 25.0;
|
||||
popUpSubtitleSize = 20.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 25.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = size!.width - (size!.width * 0.1);
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 20.0;
|
||||
popUpSubtitleSize = 18.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 15.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void setInputError() {
|
||||
messageTypes["Input Error"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 5),
|
||||
Text(
|
||||
"Oops! Looks like some fields are missing.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"We noticed that some required fields are still empty. To ensure your request is processed smoothly, please fill out all the highlighted fields before submitting the form again.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Here's a quick tip: ",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"))),
|
||||
const TextSpan(
|
||||
text: "Look for fields with an asterisk ("),
|
||||
TextSpan(
|
||||
text: "*",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"))),
|
||||
const TextSpan(
|
||||
text: ") next to them, as these are mandatory."),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setPasswordRequirementsError() {
|
||||
messageTypes["Password Requirements"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Password Doesn't Meet Requirements",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Oops! Your password doesn't quite meet our standards. To keep your account secure, please make sure your password meets the following requirements",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Requirements:\n",
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
fontSize: popUpBodySize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"))),
|
||||
const TextSpan(
|
||||
text: "1) Contailes at least 8 characters\n",
|
||||
),
|
||||
const TextSpan(
|
||||
text: "2) Contains at least 1 uppercase letter (A-Z)\n",
|
||||
),
|
||||
const TextSpan(
|
||||
text: "3) Contains at least 1 lowercase letter (a-z)\n",
|
||||
),
|
||||
const TextSpan(
|
||||
text: "4) Contains at least 1 number (0-9)\n",
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
"5) Contains at least 1 special character (!@#\$%^&*)\n",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setInvalidUsernameError() {
|
||||
messageTypes["Invalid Username"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Let's Fix That Username",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Let's create a great username for you! Just a few quick tips:\n• Your username should start with a letter.\n• You can use letters, numbers, and/ or underscores.\n• Keep it between 6 and 20 characters.\n• Avoid special characters like @, #, or \$.\"",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setInvalidEmailError() {
|
||||
messageTypes["Invalid Email"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Oops! Invalid Email",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Looks like there's a little hiccup with that email address. Please double-check that you've entered it correctly, including the \"@\" symbol and a domain (like example@email.com).",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setUserExistsError() {
|
||||
messageTypes["User Exists"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//SizedBox(height: 15),
|
||||
Text(
|
||||
"Email Already Exists",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"An account is already registered with this email address. Please try logging in or use a different email.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Here are some things to keep in mind:",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpSubtitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setPwdMatchError() {
|
||||
messageTypes["Password Match"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//SizedBox(height: 15),
|
||||
Text(
|
||||
"Passwords Don't Match",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"The password and confirm password fields do not match. Please make sure they are identical.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Here are some things to keep in mind:",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpSubtitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setinvalidCredError() {
|
||||
messageTypes["Invalid Credentials"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//SizedBox(height: 15),
|
||||
Text(
|
||||
"Uh oh! Login attempt unsuccessful.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"The email address or password you entered doesn't seem to match our records. Please double-check your information and try again.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Here are some things to keep in mind:",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpSubtitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"1) Are you sure you're using the correct email address associated with your account?\n2) Is your caps lock key on? Passwords are case-sensitive.\n3) If you've forgotten your password, no worries! Click on \"Forgot Password?\" to reset it.",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setInternetError() {
|
||||
messageTypes["Internet Connection"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Internet Connection Lost!",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"We seem to be having some trouble connecting you to the internet. This could be due to a temporary outage or an issue with your device's connection.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Here are a few things you can try:",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpSubtitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"1) Check your Wi-Fi signal strength or try connecting to a different network.\n2) Restart your device (computer, phone, etc.) and your router/modem.\n3) If you're using cellular data, ensure you have a strong signal and haven't reached your data limit.",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setLocationError() {
|
||||
messageTypes["Location Denied"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Location Services Not Enabled",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"To get the most out of MIH, we need your location. Please go to the site settings of the app and enable location services. Once you do that, we can start showing you relevant information based on your location.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
// const SizedBox(height: 15),
|
||||
// Text(
|
||||
// "Here are a few things you can try:",
|
||||
// style: TextStyle(
|
||||
// color: MihColors.getRedColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// fontSize: popUpSubtitleSize,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 10),
|
||||
// Text(
|
||||
// "1) Check your Wi-Fi signal strength or try connecting to a different network.\n2) Restart your device (computer, phone, etc.) and your router/modem.\n3) If you're using cellular data, ensure you have a strong signal and haven't reached your data limit.",
|
||||
// textAlign: TextAlign.left,
|
||||
// style: TextStyle(
|
||||
// color:
|
||||
// MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// fontSize: popUpBodySize,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget? getErrorMessage(String type) {
|
||||
return messageTypes[type];
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
size = MediaQuery.of(context).size;
|
||||
checkScreenSize();
|
||||
setInputError();
|
||||
setinvalidCredError();
|
||||
setInternetError();
|
||||
setUserExistsError();
|
||||
setPwdMatchError();
|
||||
setPasswordRequirementsError();
|
||||
setInvalidEmailError();
|
||||
setInvalidUsernameError();
|
||||
setLocationError();
|
||||
//print(size);
|
||||
// setState(() {
|
||||
// width = size.width;
|
||||
// height = size.height;
|
||||
// });
|
||||
return Dialog(child: getErrorMessage(widget.errorType));
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import '../../main.dart';
|
||||
import 'package:gif_view/gif_view.dart';
|
||||
|
||||
class Mihloadingcircle extends StatefulWidget {
|
||||
final String? message;
|
||||
const Mihloadingcircle({super.key, this.message});
|
||||
|
||||
@override
|
||||
State<Mihloadingcircle> createState() => _MihloadingcircleState();
|
||||
}
|
||||
|
||||
class _MihloadingcircleState extends State<Mihloadingcircle> {
|
||||
// final GifController _controller = GifController();
|
||||
late double popUpPaddingSize;
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = 250;
|
||||
popUpheight = 250;
|
||||
popUpPaddingSize = 25.0;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = 250;
|
||||
popUpheight = 250;
|
||||
popUpPaddingSize = 15.0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
//_controller.animateTo(26);
|
||||
super.initState();
|
||||
checkScreenSize();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// _controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
child: IntrinsicWidth(
|
||||
child: IntrinsicHeight(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
// width: 250,
|
||||
// height: 275,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GifView.asset(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.loadingImageLocation(),
|
||||
height: 200,
|
||||
width: 200,
|
||||
frameRate: 30,
|
||||
),
|
||||
widget.message != null
|
||||
? Text(
|
||||
widget.message!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
: SizedBox(),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
class MIHSuccessMessage extends StatefulWidget {
|
||||
final String successType;
|
||||
final String successMessage;
|
||||
const MIHSuccessMessage({
|
||||
super.key,
|
||||
required this.successType,
|
||||
required this.successMessage,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHSuccessMessage> createState() => _MIHSuccessMessageState();
|
||||
}
|
||||
|
||||
class _MIHSuccessMessageState extends State<MIHSuccessMessage> {
|
||||
var messageTypes = <String, Widget>{};
|
||||
late String message;
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
late double popUpTitleSize;
|
||||
late double popUpSubtitleSize;
|
||||
late double popUpBodySize;
|
||||
late double popUpIconSize;
|
||||
late double popUpPaddingSize;
|
||||
late Size? size;
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = (size!.width / 4) * 2;
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 25.0;
|
||||
popUpSubtitleSize = 20.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 25.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = size!.width - (size!.width * 0.1);
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 20.0;
|
||||
popUpSubtitleSize = 18.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 15.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void setSuccessmessage() {
|
||||
messageTypes["Success"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.check_circle_outline_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Success!",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Center(
|
||||
child: Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget? getSuccessMessage(String type) {
|
||||
return messageTypes[type];
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
size = MediaQuery.of(context).size;
|
||||
checkScreenSize();
|
||||
message = widget.successMessage;
|
||||
setSuccessmessage();
|
||||
return Dialog(child: getSuccessMessage(widget.successType));
|
||||
}
|
||||
}
|
||||
@@ -1,519 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
class MIHWarningMessage extends StatefulWidget {
|
||||
final String warningType;
|
||||
const MIHWarningMessage({
|
||||
super.key,
|
||||
required this.warningType,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHWarningMessage> createState() => _MIHDeleteMessageState();
|
||||
}
|
||||
|
||||
class _MIHDeleteMessageState extends State<MIHWarningMessage> {
|
||||
var messageTypes = <String, Widget>{};
|
||||
late double popUpWidth;
|
||||
late double? popUpheight;
|
||||
late double popUpTitleSize;
|
||||
late double popUpSubtitleSize;
|
||||
late double popUpBodySize;
|
||||
late double popUpIconSize;
|
||||
late double popUpPaddingSize;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
void checkScreenSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
setState(() {
|
||||
popUpWidth = (width / 4) * 2;
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 25.0;
|
||||
popUpSubtitleSize = 20.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 25.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
popUpWidth = width - (width * 0.1);
|
||||
popUpheight = null;
|
||||
popUpTitleSize = 20.0;
|
||||
popUpSubtitleSize = 18.0;
|
||||
popUpBodySize = 15;
|
||||
popUpPaddingSize = 15.0;
|
||||
popUpIconSize = 100;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void setNoAccess() {
|
||||
messageTypes["No Access"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Access Pending",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Your access request is currently being reviewed.\nOnce approved, you'll be able to view patient data.\nPlease follow up with the patient to approve your access request.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setNoPatientAccess() {
|
||||
messageTypes["No Patient Access"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Patient Profile Access Needed",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"To proceed with booking an appointment, you must have access to the patient's profile. This will allow you to view their medical history and other relevant information. Please contact the appropriate administrator to request access.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setAppointmentCanelled() {
|
||||
messageTypes["Appointment Canelled"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Appointment Cancelled",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"This appointment has been canceled. As a result, you no longer have access to the patient's profile. If you would like to view the patient's profile again, please book a new appointment.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setAccessCanelled() {
|
||||
messageTypes["Access Cancelled"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Access Cancelled",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"This appointment has been canceled. As a result, access has been cancelled and the doctor no longer have access to the patient's profile. If you would like them to view the patient's profile again, please book a new appointment through them.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setAccessDeclined() {
|
||||
messageTypes["Access Declined"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Access Declined",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Your request to access the patient's profile has been denied. Please contact the patient directly to inquire about the reason for this restriction.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void setExpiredAccess() {
|
||||
messageTypes["Expired Access"] = Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(popUpPaddingSize),
|
||||
width: popUpWidth,
|
||||
height: popUpheight,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 5.0),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: popUpIconSize,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//const SizedBox(height: 15),
|
||||
Text(
|
||||
"Access Expired",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpTitleSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"You no longer have access to this patient profile. The authorized access period has ended. Access to a patients profile is limited to 7 days from appointment date.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: popUpBodySize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget? getDeleteMessage(String type) {
|
||||
return messageTypes[type];
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
checkScreenSize();
|
||||
setNoAccess();
|
||||
setExpiredAccess();
|
||||
setAccessDeclined();
|
||||
setAppointmentCanelled();
|
||||
setAccessCanelled();
|
||||
//print(size);
|
||||
// setState(() {
|
||||
// width = size.width;
|
||||
// height = size.height;
|
||||
// });
|
||||
return Dialog(child: getDeleteMessage(widget.warningType));
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihColors {
|
||||
static Color getPrimaryColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0XFF3A4454);
|
||||
} else {
|
||||
return const Color(0XFFbedcfe);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getSecondaryColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0XFFbedcfe);
|
||||
} else {
|
||||
return const Color(0XFF3A4454);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getHighlightColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0XFF9bc7fa);
|
||||
} else {
|
||||
return const Color(0XFF354866);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getGreyColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0XFFc8c8c8);
|
||||
} else {
|
||||
return const Color(0XFF747474);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getGreenColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0xff8ae290);
|
||||
} else {
|
||||
return const Color(0xffB0F2B4);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getRedColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0xffD87E8B);
|
||||
} else {
|
||||
return const Color(0xffbb3d4f);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getPinkColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0xffdaa2e9);
|
||||
} else {
|
||||
// Add a different shade of pink for light mode
|
||||
return const Color(0xffdaa2e9);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getOrangeColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0xffd69d7d);
|
||||
} else {
|
||||
// Add a different shade of pink for light mode
|
||||
return const Color(0xffd69d7d);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getYellowColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0xfff4e467);
|
||||
} else {
|
||||
// Add a different shade of pink for light mode
|
||||
return const Color(0xffd4af37);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getBluishPurpleColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0xff6e7dcc);
|
||||
} else {
|
||||
// Add a different shade of pink for light mode
|
||||
return const Color(0xff6e7dcc);
|
||||
}
|
||||
}
|
||||
|
||||
static Color getPurpleColor(bool darkMode) {
|
||||
if (darkMode == true) {
|
||||
return const Color(0xffb682e7);
|
||||
} else {
|
||||
// Add a different shade of pink for light mode
|
||||
return const Color(0xffb682e7);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import "package:universal_html/html.dart" as html;
|
||||
|
||||
class MihTheme {
|
||||
// late int _mainColor;
|
||||
// late int _secondColor;
|
||||
//late int _errColor;
|
||||
//late int _succColor;
|
||||
// late int _mesColor;
|
||||
late String mode;
|
||||
late String screenType;
|
||||
late AssetImage loading;
|
||||
late String loadingAssetText;
|
||||
late TargetPlatform platform;
|
||||
bool kIsWeb = const bool.fromEnvironment('dart.library.js_util');
|
||||
String latestVersion = "1.2.1";
|
||||
// Options:-
|
||||
// f3f9d2 = Cream
|
||||
// f0f0c9 = cream2
|
||||
// caffd0 = light green
|
||||
// B0F2B4 = light grean 2 *
|
||||
// 85bda6 = light green 3
|
||||
// 70f8ba = green
|
||||
// F7F3EA = white
|
||||
// a63446 = red
|
||||
//747474
|
||||
|
||||
MihTheme() {
|
||||
mode = "Dark";
|
||||
//_errColor = 0xffD87E8B;
|
||||
//_succColor = 0xffB0F2B4;
|
||||
//_mesColor = 0xffc8c8c8d9;
|
||||
}
|
||||
|
||||
ThemeData getData(bool bool) {
|
||||
return ThemeData(
|
||||
fontFamily: 'Segoe UI',
|
||||
scaffoldBackgroundColor: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
// pageTransitionsTheme: PageTransitionsTheme(
|
||||
// builders: Map<TargetPlatform, PageTransitionsBuilder>.fromIterable(
|
||||
// TargetPlatform.values,
|
||||
// value: (dynamic _) => const FadeUpwardsPageTransitionsBuilder(),
|
||||
// ),
|
||||
// ),
|
||||
colorScheme: ColorScheme(
|
||||
brightness: getBritness(),
|
||||
primary: MihColors.getSecondaryColor(mode == "Dark"),
|
||||
onPrimary: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
secondary: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
onSecondary: MihColors.getSecondaryColor(mode == "Dark"),
|
||||
error: MihColors.getRedColor(mode == "Dark"),
|
||||
onError: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
surface: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
onSurface: MihColors.getSecondaryColor(mode == "Dark"),
|
||||
),
|
||||
datePickerTheme: DatePickerThemeData(
|
||||
backgroundColor: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
headerBackgroundColor: MihColors.getSecondaryColor(mode == "Dark"),
|
||||
headerForegroundColor: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
),
|
||||
appBarTheme: AppBarTheme(
|
||||
color: MihColors.getSecondaryColor(mode == "Dark"),
|
||||
foregroundColor: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
titleTextStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
floatingActionButtonTheme: FloatingActionButtonThemeData(
|
||||
backgroundColor: MihColors.getSecondaryColor(mode == "Dark"),
|
||||
foregroundColor: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
extendedTextStyle:
|
||||
TextStyle(color: MihColors.getPrimaryColor(mode == "Dark")),
|
||||
),
|
||||
drawerTheme: DrawerThemeData(
|
||||
backgroundColor: MihColors.getPrimaryColor(mode == "Dark"),
|
||||
));
|
||||
}
|
||||
|
||||
String getPlatform() {
|
||||
// if (isPwa()) {
|
||||
// if (platform == TargetPlatform.android) {
|
||||
// return "Android";
|
||||
// } else if (platform == TargetPlatform.iOS) {
|
||||
// return "iOS";
|
||||
// }
|
||||
// } else
|
||||
if (kIsWeb) {
|
||||
return "Web";
|
||||
} else if (!kIsWeb) {
|
||||
if (platform == TargetPlatform.android) {
|
||||
return "Android";
|
||||
} else if (platform == TargetPlatform.iOS) {
|
||||
return "iOS";
|
||||
}
|
||||
}
|
||||
return "Other";
|
||||
}
|
||||
|
||||
bool isPwa() {
|
||||
return html.window.matchMedia('(display-mode: standalone)').matches;
|
||||
}
|
||||
|
||||
void setMode(String m) {
|
||||
mode;
|
||||
}
|
||||
|
||||
String getLatestVersion() {
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
ThemeData getThemeData() {
|
||||
return getData(mode == "Dark");
|
||||
}
|
||||
|
||||
ThemeData darkMode() {
|
||||
return getData(mode == "Dark");
|
||||
}
|
||||
|
||||
ThemeData lightMode() {
|
||||
return getData(mode == "Dark");
|
||||
}
|
||||
|
||||
Brightness getBritness() {
|
||||
if (mode == "Dark") {
|
||||
return Brightness.dark;
|
||||
} else {
|
||||
return Brightness.light;
|
||||
}
|
||||
}
|
||||
|
||||
// Color messageTextColor() {
|
||||
// if (mode == "Dark") {
|
||||
// _mesColor = 0XFFc8c8c8;
|
||||
// } else {
|
||||
// _mesColor = 0XFF747474;
|
||||
// }
|
||||
// return Color(_mesColor);
|
||||
// }
|
||||
|
||||
// Color errorColor() {
|
||||
// if (mode == "Dark") {
|
||||
// return const Color(0xffD87E8B);
|
||||
// } else {
|
||||
// return const Color(0xffbb3d4f);
|
||||
// }
|
||||
// //return Color(_errColor);
|
||||
// }
|
||||
|
||||
// Color highlightColor() {
|
||||
// if (mode == "Dark") {
|
||||
// return const Color(0XFF9bc7fa);
|
||||
// } else {
|
||||
// return const Color(0XFF354866);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Color successColor() {
|
||||
// if (mode == "Dark") {
|
||||
// return const Color(0xffB0F2B4);
|
||||
// } else {
|
||||
// return const Color(0xff56a95b);
|
||||
// }
|
||||
// }
|
||||
|
||||
AssetImage loadingImage() {
|
||||
if (mode == "Dark") {
|
||||
loading = const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_light.gif',
|
||||
);
|
||||
} else {
|
||||
loading = const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_dark.gif',
|
||||
);
|
||||
}
|
||||
return loading;
|
||||
}
|
||||
|
||||
AssetImage altLoadingImage() {
|
||||
if (mode == "Dark") {
|
||||
loading = const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_dark.gif',
|
||||
);
|
||||
} else {
|
||||
loading = const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_light.gif',
|
||||
);
|
||||
}
|
||||
return loading;
|
||||
}
|
||||
|
||||
String loadingImageLocation() {
|
||||
if (mode == "Dark") {
|
||||
loadingAssetText =
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_light.gif';
|
||||
} else {
|
||||
loadingAssetText =
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_dark.gif';
|
||||
}
|
||||
return loadingAssetText;
|
||||
}
|
||||
|
||||
String altLoadingImageLocation() {
|
||||
if (mode == "Dark") {
|
||||
loadingAssetText =
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_dark.gif';
|
||||
} else {
|
||||
loadingAssetText =
|
||||
'lib/mih_components/mih_package_components/assets/images/loading_light.gif';
|
||||
}
|
||||
return loadingAssetText;
|
||||
}
|
||||
|
||||
AssetImage aiLogoImage() {
|
||||
if (mode == "Dark") {
|
||||
return const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/mzansi_ai-dark.png',
|
||||
);
|
||||
} else {
|
||||
return const AssetImage(
|
||||
'lib/mih_components/mih_package_components/assets/images/mzansi_ai-light.png',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void setScreenType(double width) {
|
||||
if (width <= 800) {
|
||||
screenType = "mobile";
|
||||
} else {
|
||||
screenType = "desktop";
|
||||
}
|
||||
}
|
||||
|
||||
// Color MihColors.getPrimaryColor(mode == "Dark") {
|
||||
// if (mode == "Dark") {
|
||||
// _mainColor = 0XFF3A4454;
|
||||
// } else {
|
||||
// _mainColor = 0XFFbedcfe;
|
||||
// }
|
||||
// return Color(_mainColor);
|
||||
// }
|
||||
|
||||
// Color MihColors.getSecondaryColor(mode == "Dark") {
|
||||
// if (mode == "Dark") {
|
||||
// _secondColor = 0XFFbedcfe;
|
||||
// } else {
|
||||
// _secondColor = 0XFF3A4454;
|
||||
// }
|
||||
// return Color(_secondColor);
|
||||
// }
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class AboutMihTile extends StatefulWidget {
|
||||
final double packageSize;
|
||||
final bool personalSelected;
|
||||
const AboutMihTile({
|
||||
super.key,
|
||||
required this.packageSize,
|
||||
required this.personalSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AboutMihTile> createState() => _AboutMihTileState();
|
||||
}
|
||||
|
||||
class _AboutMihTileState extends State<AboutMihTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"aboutMih",
|
||||
extra: AboutArguments(
|
||||
widget.personalSelected,
|
||||
0,
|
||||
),
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/about',
|
||||
// arguments: 0,
|
||||
// );
|
||||
},
|
||||
appName: "About MIH",
|
||||
appIcon: Icon(
|
||||
MihIcons.aboutMih,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: widget.packageSize,
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
primaryColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class MihAttributes extends StatefulWidget {
|
||||
const MihAttributes({super.key});
|
||||
|
||||
@override
|
||||
State<MihAttributes> createState() => _MihAttributesState();
|
||||
}
|
||||
|
||||
class _MihAttributesState extends State<MihAttributes> {
|
||||
Future<void> launchUrlLink(Uri linkUrl) async {
|
||||
if (!await launchUrl(linkUrl)) {
|
||||
throw Exception('Could not launch $linkUrl');
|
||||
}
|
||||
}
|
||||
|
||||
TableRow displayIcon(IconData icon, String creator, String link) {
|
||||
return TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||
child: SizedBox(
|
||||
height: 150,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 15.0),
|
||||
child: FittedBox(
|
||||
child: Center(
|
||||
child: Icon(
|
||||
icon,
|
||||
// size: 125,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
creator,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 15.0),
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
launchUrlLink(
|
||||
Uri.parse(
|
||||
link,
|
||||
),
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 100,
|
||||
child: Text(
|
||||
"Visit",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem: getBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
String message =
|
||||
"Some APIs, Icons and Assets used in MIH were sourced from third party providers.\n";
|
||||
message +=
|
||||
"We are grateful to the talented creators for providing these resources.\n";
|
||||
message +=
|
||||
"As per the terms for free use for these third party providers, the following assets require attribution";
|
||||
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(
|
||||
MihIcons.mihLogo,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 165,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
SelectableText(
|
||||
message,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: Table(
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
columnWidths: const {
|
||||
0: FlexColumnWidth(1),
|
||||
1: FlexColumnWidth(1),
|
||||
2: FlexColumnWidth(1),
|
||||
},
|
||||
children: [
|
||||
const TableRow(
|
||||
children: [
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 15.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Resources",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 15.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Creator",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 15.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Link",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
displayIcon(MihIcons.mihRing, "Tarah Meth",
|
||||
"https://www.linkedin.com/in/tarah-meth-3b6309254/"),
|
||||
displayIcon(MihIcons.mihLogo, "Tarah Meth",
|
||||
"https://www.linkedin.com/in/tarah-meth-3b6309254/"),
|
||||
displayIcon(MihIcons.mzansiAi, "Ollama", "https://ollama.com/"),
|
||||
displayIcon(MihIcons.mzansiWallet, "Freepik",
|
||||
"https://www.flaticon.com/free-icon/wallet-passes-app_3884407?term=wallet&page=1&position=21&origin=search&related_id=3884407"),
|
||||
displayIcon(MihIcons.patientProfile, "RaftelDesign",
|
||||
"https://www.flaticon.com/free-icon/patient_2376100?term=medication&page=1&position=6&origin=search&related_id=2376100"),
|
||||
displayIcon(MihIcons.patientProfile, "Srip",
|
||||
"https://www.flaticon.com/free-icon/hospital_1233930?term=medical+snake&page=1&position=7&origin=search&related_id=1233930"),
|
||||
displayIcon(MihIcons.calendar, "Freepik",
|
||||
"https://www.flaticon.com/free-icon/calendar_2278049?term=calendar&page=1&position=5&origin=search&related_id=2278049"),
|
||||
displayIcon(MihIcons.calculator, "Freepik",
|
||||
"https://www.flaticon.com/free-icon/calculator_2374409?term=calculator&page=1&position=20&origin=search&related_id=2374409"),
|
||||
displayIcon(MihIcons.aboutMih, "Chanut",
|
||||
"https://www.flaticon.com/free-icon/info_151776?term=about&page=1&position=8&origin=search&related_id=151776"),
|
||||
displayIcon(MihIcons.personalProfile, "Freepik",
|
||||
"https://www.flaticon.com/free-icon/user_1077063?term=profile&page=1&position=6&origin=search&related_id=1077063"),
|
||||
displayIcon(MihIcons.businessProfile, "Gravisio",
|
||||
"https://www.flaticon.com/free-icon/contractor_11813336?term=company+profile&page=1&position=2&origin=search&related_id=11813336"),
|
||||
displayIcon(MihIcons.patientManager, "Vector Tank",
|
||||
"https://www.flaticon.com/free-icon/doctor_10215061?term=doctor&page=1&position=73&origin=search&related_id=10215061"),
|
||||
displayIcon(MihIcons.profileSetup, "Freepik",
|
||||
"https://www.flaticon.com/free-icon/add-user_748137?term=profile+add&page=1&position=1&origin=search&related_id=748137"),
|
||||
displayIcon(MihIcons.businessSetup, "kerismaker",
|
||||
"https://www.flaticon.com/free-icon/business_13569850?term=company+add&page=1&position=25&origin=search&related_id=13569850"),
|
||||
displayIcon(MihIcons.calculator, "fawazahmed0",
|
||||
"https://github.com/fawazahmed0/exchange-api"),
|
||||
displayIcon(MihIcons.iDontKnow, "Freepik",
|
||||
"https://www.flaticon.com/free-icon/i-dont-know_5359909?term=i+dont+know&page=1&position=7&origin=search&related_id=5359909"),
|
||||
],
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: 500,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// const SizedBox(
|
||||
// width: double.infinity,
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Flexible(
|
||||
// child: Text(
|
||||
// "Icon",
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Flexible(
|
||||
// child: Text(
|
||||
// "Creator",
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Flexible(
|
||||
// child: Text(
|
||||
// "Link",
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// const Padding(
|
||||
// padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||
// child: Divider(),
|
||||
// ),
|
||||
// displayIcon(MihIcons.mihLogo, "Tarah Meth",
|
||||
// "https://app.mzansi-innovation-hub.co.za/"),
|
||||
// const SizedBox(height: 10),
|
||||
// displayIcon(MihIcons.mihLogo, "Test",
|
||||
// "https://www.flaticon.com/free-icons/mih"),
|
||||
// const SizedBox(height: 10),
|
||||
// displayIcon(MihIcons.mihLogo, "Test",
|
||||
// "https://www.flaticon.com/free-icons/mih"),
|
||||
// const SizedBox(height: 10),
|
||||
// displayIcon(MihIcons.mihLogo, "Test",
|
||||
// "https://www.flaticon.com/free-icons/mih"),
|
||||
// const SizedBox(height: 10),
|
||||
// ],
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,960 +0,0 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_install_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:redacted/redacted.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
class MihInfo extends StatefulWidget {
|
||||
const MihInfo({super.key});
|
||||
|
||||
@override
|
||||
State<MihInfo> createState() => _MihInfoState();
|
||||
}
|
||||
|
||||
class _MihInfoState extends State<MihInfo> {
|
||||
late Future<int> _futureUserCount;
|
||||
late Future<int> _futureBusinessCount;
|
||||
final Uri _tiktokUrl =
|
||||
Uri.parse('https://www.tiktok.com/@mzansi.innovation.hub');
|
||||
final Uri _whatsappUrl =
|
||||
Uri.parse('https://whatsapp.com/channel/0029Vax3INCIyPtMn8KgeM2F');
|
||||
final Uri _twitch = Uri.parse('https://www.twitch.tv/mzansi_innovation_hub');
|
||||
final Uri _kick = Uri.parse('https://kick.com/mzansi-innovation-hub');
|
||||
final Uri _threadsUrl =
|
||||
Uri.parse('https://www.threads.net/@mzansi.innovation.hub');
|
||||
final Uri _instagramUrl =
|
||||
Uri.parse('https://www.instagram.com/mzansi.innovation.hub');
|
||||
final Uri _youtubeUrl =
|
||||
Uri.parse('https://www.youtube.com/@mzansiinnovationhub');
|
||||
final Uri _xUrl = Uri.parse('https://x.com/mzansi_inno_hub');
|
||||
final Uri _linkedinUrl =
|
||||
Uri.parse('https://www.linkedin.com/company/mzansi-innovation-hub/');
|
||||
final Uri _facebookUrl =
|
||||
Uri.parse('https://www.facebook.com/profile.php?id=61565345762136');
|
||||
final Uri _redditUrl =
|
||||
Uri.parse('https://www.reddit.com/r/Mzani_Innovation_Hub/');
|
||||
|
||||
Widget founderBio() {
|
||||
String bio = "";
|
||||
bio += "BSc Computer Science & Information Systems\n";
|
||||
bio += "(University of the Western Cape)\n";
|
||||
bio +=
|
||||
"6 Year of banking experience with one of the big 5 banks of South Africa.";
|
||||
return Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 300,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
fit: StackFit.loose,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
backgroundImage: const AssetImage(
|
||||
"lib/mih_components/mih_package_components/assets/images/founder.jpg"),
|
||||
//'https://media.licdn.com/dms/image/D4D03AQGd1-QhjtWWpA/profile-displayphoto-shrink_400_400/0/1671698053061?e=2147483647&v=beta&t=a3dJI5yxs5-KeXjj10LcNCFuC9IOfa8nNn3k_Qyr0CA'),
|
||||
radius: 75,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
MihIcons.mihRing,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 400,
|
||||
child: Text(
|
||||
bio,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
//fontWeight: FontWeight.bold,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget founderTitle() {
|
||||
String heading = "Yasien Meth (Founder & CEO)";
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
heading,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget ourVision() {
|
||||
String heading = "Our Vision";
|
||||
String vision =
|
||||
"Digitizing Mzansi one process at a time. Discover essential Mzansi apps to streamline your personal and professional life. Simplify your daily tasks with our user-friendly solutions.";
|
||||
|
||||
return SizedBox(
|
||||
width: 500,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
heading,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
vision,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
//fontWeight: FontWeight.bold,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget ourMission() {
|
||||
String heading = "Our Mission";
|
||||
String mission =
|
||||
"Bridge the digital divide in Mzansi, ensuring that everyone can benefit from the power of technology. We empower lives by providing simple, elegant solutions that elevate daily experiences. With our user-friendly approach, we're making the digital world accessible to all, ensuring no one is left behind in the digital revolution.";
|
||||
|
||||
return SizedBox(
|
||||
width: 500,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
heading,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
mission,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
//fontWeight: FontWeight.bold,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget mihSocials() {
|
||||
String heading = "Follow Our Journey";
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
heading,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
SizedBox(
|
||||
width: 500,
|
||||
height: 600,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.only(
|
||||
// left: width / 10,
|
||||
// right: width / 10,
|
||||
// //bottom: height / 5,
|
||||
// top: 20,
|
||||
),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
// shrinkWrap: true,
|
||||
itemCount: getSocialsList().length,
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 15, maxCrossAxisExtent: 150),
|
||||
itemBuilder: (context, index) {
|
||||
return getSocialsList()[index];
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getSocialsList() {
|
||||
List<Widget> socials = [];
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_youtubeUrl);
|
||||
},
|
||||
tileName: "YouTube",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.youtube,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 175,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_tiktokUrl);
|
||||
},
|
||||
tileName: "TikTok",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.tiktok,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_twitch);
|
||||
},
|
||||
tileName: "Twitch",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.twitch,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_threadsUrl);
|
||||
},
|
||||
tileName: "Threads",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.threads,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_whatsappUrl);
|
||||
},
|
||||
tileName: "Whatsapp",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.whatsapp,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_instagramUrl);
|
||||
},
|
||||
tileName: "Instagram",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.instagram,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_xUrl);
|
||||
},
|
||||
tileName: "X",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.xTwitter,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_linkedinUrl);
|
||||
},
|
||||
tileName: "LinkedIn",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.linkedin,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_facebookUrl);
|
||||
},
|
||||
tileName: "FaceBook",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.facebook,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_redditUrl);
|
||||
},
|
||||
tileName: "Reddit",
|
||||
tileIcon: Center(
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.reddit,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
size: 200,
|
||||
),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
socials.add(MIHTile(
|
||||
onTap: () {
|
||||
launchSocialUrl(_kick);
|
||||
},
|
||||
tileName: "Kick",
|
||||
tileIcon: Center(
|
||||
child: Text(
|
||||
"KICK",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 100,
|
||||
),
|
||||
),
|
||||
// FaIcon(
|
||||
// FontAwesomeIcons.tv,
|
||||
// color: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: 200,
|
||||
// ),
|
||||
),
|
||||
p: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
s: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
));
|
||||
//==================================================================
|
||||
return socials;
|
||||
}
|
||||
|
||||
Future<void> launchSocialUrl(Uri linkUrl) async {
|
||||
if (!await launchUrl(linkUrl)) {
|
||||
throw Exception('Could not launch $linkUrl');
|
||||
}
|
||||
}
|
||||
|
||||
Widget getInstallButtonText() {
|
||||
final isWebAndroid =
|
||||
kIsWeb && (defaultTargetPlatform == TargetPlatform.android);
|
||||
final isWebIos = kIsWeb && (defaultTargetPlatform == TargetPlatform.iOS);
|
||||
String btnText = "";
|
||||
IconData platformIcon;
|
||||
if (isWebAndroid) {
|
||||
btnText = "Install MIH";
|
||||
platformIcon = FontAwesomeIcons.googlePlay;
|
||||
} else if (isWebIos) {
|
||||
btnText = "Install MIH";
|
||||
platformIcon = FontAwesomeIcons.appStoreIos;
|
||||
} else if (MzansiInnovationHub.of(context)!.theme.getPlatform() ==
|
||||
"Android") {
|
||||
btnText = "Update MIH";
|
||||
platformIcon = FontAwesomeIcons.googlePlay;
|
||||
} else if (MzansiInnovationHub.of(context)!.theme.getPlatform() == "iOS") {
|
||||
btnText = "Update MIH";
|
||||
platformIcon = FontAwesomeIcons.appStoreIos;
|
||||
} else {
|
||||
btnText = "Install MIH";
|
||||
platformIcon = FontAwesomeIcons.globe;
|
||||
}
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FaIcon(
|
||||
platformIcon,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
btnText,
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void shareMIHLink(BuildContext context, String message, String link) {
|
||||
String shareText = "$message: $link";
|
||||
Share.share(
|
||||
shareText,
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayBusinessCount() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FutureBuilder<int>(
|
||||
future: _futureBusinessCount,
|
||||
builder: (context, snapshot) {
|
||||
bool isLoading = true;
|
||||
String userCount = "⚠️";
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
isLoading = true;
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasError) {
|
||||
isLoading = false;
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
isLoading = false;
|
||||
userCount = snapshot.data.toString();
|
||||
} else {
|
||||
isLoading = true;
|
||||
}
|
||||
return SizedBox(
|
||||
child: Text(
|
||||
userCount,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 23,
|
||||
),
|
||||
),
|
||||
).redacted(
|
||||
context: context,
|
||||
redact: isLoading,
|
||||
configuration: RedactedConfiguration(
|
||||
defaultBorderRadius: BorderRadius.circular(5),
|
||||
redactedColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark",
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
"Businesses",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayUserCount() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FutureBuilder<int>(
|
||||
future: _futureUserCount,
|
||||
builder: (context, snapshot) {
|
||||
bool isLoading = true;
|
||||
String userCount = "⚠️";
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
isLoading = true;
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasError) {
|
||||
isLoading = false;
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
isLoading = false;
|
||||
userCount = snapshot.data.toString();
|
||||
} else {
|
||||
isLoading = true;
|
||||
}
|
||||
return SizedBox(
|
||||
child: Text(
|
||||
userCount,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 23,
|
||||
),
|
||||
),
|
||||
).redacted(
|
||||
context: context,
|
||||
redact: isLoading,
|
||||
configuration: RedactedConfiguration(
|
||||
defaultBorderRadius: BorderRadius.circular(5),
|
||||
redactedColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark",
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
"Users",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_futureUserCount = MihUserServices().fetchUserCount();
|
||||
_futureBusinessCount = MihBusinessDetailsServices().fetchBusinessCount();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem: getBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 165,
|
||||
child: FittedBox(
|
||||
child: Icon(
|
||||
MihIcons.mihLogo,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text(
|
||||
"Mzansi Innovation Hub",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 30,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"MIH App Version: ${MzansiInnovationHub.of(context)!.theme.getLatestVersion()}",
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
// ===================== Divider
|
||||
// Padding(
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// vertical: 10.0,
|
||||
// horizontal: 25,
|
||||
// ),
|
||||
// child: Divider(
|
||||
// thickness: 1,
|
||||
// color: MihColors.getGreyColor(
|
||||
// MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
// Text(
|
||||
// "The MIH Community",
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontSize: 22,
|
||||
// ),
|
||||
// ),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceAround,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 25,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
displayUserCount(),
|
||||
displayBusinessCount(),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"The MIH Community",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 22,
|
||||
),
|
||||
),
|
||||
// ===================== Divider
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 25,
|
||||
),
|
||||
child: Divider(
|
||||
thickness: 1,
|
||||
color: MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
// const SizedBox(
|
||||
// height: 10,
|
||||
// ),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
ourVision(),
|
||||
ourMission(),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
MihInstallServices().installMihTrigger(context);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: getInstallButtonText(),
|
||||
),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
launchSocialUrl(
|
||||
Uri.parse(
|
||||
"https://www.youtube.com/playlist?list=PLuT35kJIui0H5kXjxNOZlHoOPZbQLr4qh",
|
||||
),
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FaIcon(
|
||||
FontAwesomeIcons.youtube,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
"MIH Beginners Guide",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
launchSocialUrl(
|
||||
Uri.parse(
|
||||
"https://patreon.com/MzansiInnovationHub?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink",
|
||||
),
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FaIcon(
|
||||
FontAwesomeIcons.patreon,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
"Support Our Journey",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
// ===================== Divider
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 25,
|
||||
),
|
||||
child: Divider(
|
||||
thickness: 1,
|
||||
color: MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
children: [
|
||||
founderTitle(),
|
||||
founderBio(),
|
||||
],
|
||||
),
|
||||
// ===================== Divider
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 25,
|
||||
),
|
||||
child: Divider(
|
||||
thickness: 1,
|
||||
color: MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
mihSocials(),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.share,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.vpn_lock,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "MIH - Web",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
shareMIHLink(
|
||||
context,
|
||||
"Check out the MIH app on the Web",
|
||||
"https://app.mzansi-innovation-hub.co.za/",
|
||||
);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.apple,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "MIH - iOS",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
shareMIHLink(
|
||||
context,
|
||||
"Check out the MIH app on the App Store",
|
||||
"https://apps.apple.com/za/app/mzansi-innovation-hub/id6743310890",
|
||||
);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.android,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "MIH - Android",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
shareMIHLink(
|
||||
context,
|
||||
"Check out the MIH app on the Play Store",
|
||||
"https://play.google.com/store/apps/details?id=za.co.mzansiinnovationhub.mih",
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/access_review/package_tools/mih_access_requests.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MihAccess extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
const MihAccess({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihAccess> createState() => _MihAccessState();
|
||||
}
|
||||
|
||||
class _MihAccessState extends State<MihAccess> {
|
||||
int _selcetedIndex = 0;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
print("Index: $_selcetedIndex");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: true,
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.people)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
MihAccessRequest(
|
||||
signedInUser: widget.signedInUser,
|
||||
),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Access",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihAccessTile extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final double packageSize;
|
||||
|
||||
const MihAccessTile({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihAccessTile> createState() => _MihAccessTileState();
|
||||
}
|
||||
|
||||
class _MihAccessTileState extends State<MihAccessTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
authenticateUser: true,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mihAccess",
|
||||
extra: widget.signedInUser,
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/mih-access',
|
||||
// arguments: widget.signedInUser,
|
||||
// );
|
||||
},
|
||||
appName: "Access Controls",
|
||||
appIcon: Icon(
|
||||
MihIcons.accessControl,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: widget.packageSize,
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
primaryColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,320 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_dropdwn_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../mih_services/mih_service_calls.dart';
|
||||
import '../../../mih_components/mih_layout/mih_action.dart';
|
||||
import '../../../mih_components/mih_layout/mih_header.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import '../../../mih_config/mih_env.dart';
|
||||
import '../../../mih_components/mih_objects/app_user.dart';
|
||||
import '../../../mih_components/mih_objects/patient_access.dart';
|
||||
import '../builder/build_business_access_list.dart';
|
||||
|
||||
class MihAccessRequest extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
|
||||
const MihAccessRequest({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihAccessRequest> createState() => _MihAccessRequestState();
|
||||
}
|
||||
|
||||
class _MihAccessRequestState extends State<MihAccessRequest> {
|
||||
TextEditingController filterController = TextEditingController();
|
||||
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
String errorCode = "";
|
||||
String errorBody = "";
|
||||
String datefilter = "";
|
||||
String accessFilter = "";
|
||||
bool forceRefresh = false;
|
||||
late String selectedDropdown;
|
||||
|
||||
late Future<List<PatientAccess>> accessList;
|
||||
|
||||
// Future<List<AccessRequest>> fetchAccessRequests() async {
|
||||
// //print("Patien manager page: $endpoint");
|
||||
// final response = await http.get(
|
||||
// Uri.parse("$baseUrl/access-requests/${widget.signedInUser.app_id}"));
|
||||
// // print("Here");
|
||||
// // print("Body: ${response.body}");
|
||||
// // print("Code: ${response.statusCode}");
|
||||
// errorCode = response.statusCode.toString();
|
||||
// errorBody = response.body;
|
||||
|
||||
// if (response.statusCode == 200) {
|
||||
// //print("Here1");
|
||||
// Iterable l = jsonDecode(response.body);
|
||||
// //print("Here2");
|
||||
// List<AccessRequest> patientQueue = List<AccessRequest>.from(
|
||||
// l.map((model) => AccessRequest.fromJson(model)));
|
||||
// //print("Here3");
|
||||
// //print(patientQueue);
|
||||
// return patientQueue;
|
||||
// } else {
|
||||
// throw Exception('failed to load patients');
|
||||
// }
|
||||
// }
|
||||
|
||||
List<PatientAccess> filterSearchResults(List<PatientAccess> accessList) {
|
||||
List<PatientAccess> templist = [];
|
||||
|
||||
for (var item in accessList) {
|
||||
if (filterController.text == "All") {
|
||||
templist.add(item);
|
||||
} else {
|
||||
if (item.status.contains(filterController.text.toLowerCase())) {
|
||||
templist.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return templist;
|
||||
}
|
||||
|
||||
void refreshList() {
|
||||
if (forceRefresh == true) {
|
||||
setState(() {
|
||||
accessList = MIHApiCalls.getBusinessAccessListOfPatient(
|
||||
widget.signedInUser.app_id);
|
||||
forceRefresh = false;
|
||||
});
|
||||
} else if (selectedDropdown != filterController.text) {
|
||||
setState(() {
|
||||
accessList = MIHApiCalls.getBusinessAccessListOfPatient(
|
||||
widget.signedInUser.app_id);
|
||||
selectedDropdown = filterController.text;
|
||||
});
|
||||
}
|
||||
// setState(() {
|
||||
// accessRequestResults = fetchAccessRequests();
|
||||
// });
|
||||
}
|
||||
|
||||
MIHAction getActionButton() {
|
||||
return MIHAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: false,
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MIHHeader getHeader() {
|
||||
return const MIHHeader(
|
||||
headerAlignment: MainAxisAlignment.center,
|
||||
headerItems: [
|
||||
Text(
|
||||
"Forever Access List",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Flexible(
|
||||
child: MihDropdownField(
|
||||
controller: filterController,
|
||||
hintText: "Access Type",
|
||||
dropdownOptions: const [
|
||||
"All",
|
||||
"Approved",
|
||||
"Pending",
|
||||
"Declined",
|
||||
"Cancelled",
|
||||
],
|
||||
requiredText: true,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
iconSize: 35,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
forceRefresh = true;
|
||||
});
|
||||
KenLogger.warning("Refreshing Access List");
|
||||
refreshList();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.refresh,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: accessList,
|
||||
builder: (context, snapshot) {
|
||||
//print("patient Queue List ${snapshot.hasData}");
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Mihloadingcircle();
|
||||
} else if (snapshot.connectionState == ConnectionState.done) {
|
||||
List<PatientAccess> accessRequestList;
|
||||
accessRequestList = filterSearchResults(snapshot.requireData);
|
||||
if (accessRequestList.isNotEmpty) {
|
||||
return BuildBusinessAccessList(
|
||||
signedInUser: widget.signedInUser,
|
||||
patientAccessList: accessRequestList,
|
||||
onSuccessUpate: () {
|
||||
setState(() {
|
||||
forceRefresh = true;
|
||||
});
|
||||
refreshList();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.accessControl,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No access has been granted to your MIH Profile",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
// const SizedBox(height: 10),
|
||||
// Center(
|
||||
// child: RichText(
|
||||
// textAlign: TextAlign.center,
|
||||
// text: TextSpan(
|
||||
// style: TextStyle(
|
||||
// fontSize: 20,
|
||||
// fontWeight: FontWeight.normal,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// children: [
|
||||
// TextSpan(text: "Press "),
|
||||
// WidgetSpan(
|
||||
// alignment: PlaceholderAlignment.middle,
|
||||
// child: Icon(
|
||||
// Icons.menu,
|
||||
// size: 20,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// TextSpan(
|
||||
// text: " to add your first loyalty card."),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
// return Center(
|
||||
// child: Text(
|
||||
// "No Request have been made.",
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .messageTextColor()),
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
// return Expanded(
|
||||
// child: displayAccessRequestList(accessRequestList),
|
||||
// );
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"$errorCode: Error pulling Patients Data\n$baseUrl/queue/patients/\n$errorBody",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
filterController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
selectedDropdown = "All";
|
||||
filterController.text = "All";
|
||||
filterController.addListener(refreshList);
|
||||
setState(() {
|
||||
accessList = MIHApiCalls.getBusinessAccessListOfPatient(
|
||||
widget.signedInUser.app_id);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem: getBody(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tools/currency_exchange_rate.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tools/simple_calc.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tools/tip_calc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MIHCalculator extends StatefulWidget {
|
||||
final bool personalSelected;
|
||||
const MIHCalculator({
|
||||
super.key,
|
||||
required this.personalSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHCalculator> createState() => _MIHCalculatorState();
|
||||
}
|
||||
|
||||
class _MIHCalculatorState extends State<MIHCalculator> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selectedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selectedIndex = newValue;
|
||||
});
|
||||
print("Index: $_selectedIndex");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: widget.personalSelected,
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.calculate)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 0;
|
||||
});
|
||||
};
|
||||
temp[const Icon(Icons.money)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 1;
|
||||
});
|
||||
};
|
||||
temp[const Icon(Icons.currency_exchange)] = () {
|
||||
setState(() {
|
||||
_selectedIndex = 2;
|
||||
});
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selectedIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
const SimpleCalc(),
|
||||
const TipCalc(),
|
||||
const CurrencyExchangeRate(),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Simple Calculator",
|
||||
"Tip Calculator",
|
||||
"Forex Calculator",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MihCalculatorTile extends StatefulWidget {
|
||||
final bool personalSelected;
|
||||
final double packageSize;
|
||||
|
||||
const MihCalculatorTile({
|
||||
super.key,
|
||||
required this.personalSelected,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihCalculatorTile> createState() => _MihCalculatorTileState();
|
||||
}
|
||||
|
||||
class _MihCalculatorTileState extends State<MihCalculatorTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mihCalculator",
|
||||
extra: widget.personalSelected,
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/calculator',
|
||||
// arguments: widget.personalSelected,
|
||||
// );
|
||||
},
|
||||
appName: "Calculator",
|
||||
appIcon: Icon(
|
||||
MihIcons.calculator,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: widget.packageSize,
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
primaryColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,465 +0,0 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_banner_ad.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_dropdwn_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_currency_exchange_rate_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
|
||||
class CurrencyExchangeRate extends StatefulWidget {
|
||||
const CurrencyExchangeRate({super.key});
|
||||
|
||||
@override
|
||||
State<CurrencyExchangeRate> createState() => _CurrencyExchangeRateState();
|
||||
}
|
||||
|
||||
class _CurrencyExchangeRateState extends State<CurrencyExchangeRate> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController _fromCurrencyController = TextEditingController();
|
||||
final TextEditingController _toCurrencyController = TextEditingController();
|
||||
final TextEditingController _fromAmountController = TextEditingController();
|
||||
final TextEditingController _toAmountController = TextEditingController();
|
||||
late Future<List<String>> availableCurrencies;
|
||||
MihBannerAd _bannerAd = MihBannerAd();
|
||||
|
||||
Future<void> submitForm() async {
|
||||
String fromCurrencyCode = _fromCurrencyController.text.split(" - ")[0];
|
||||
String toCurrencyCode = _toCurrencyController.text.split(" - ")[0];
|
||||
List<String> dateValue = [];
|
||||
double exchangeRate = 0;
|
||||
await MihCurrencyExchangeRateServices.getCurrencyExchangeValue(
|
||||
fromCurrencyCode, toCurrencyCode)
|
||||
.then((amount) {
|
||||
dateValue = amount;
|
||||
});
|
||||
exchangeRate = double.parse(dateValue[1]);
|
||||
double exchangeValue =
|
||||
double.parse(_fromAmountController.text) * exchangeRate;
|
||||
|
||||
print(
|
||||
"Date: ${dateValue[0]}\n${_fromAmountController.text} | $fromCurrencyCode\n$exchangeValue | $toCurrencyCode");
|
||||
displayResult(dateValue[0], _fromAmountController.text, fromCurrencyCode,
|
||||
exchangeValue, toCurrencyCode);
|
||||
}
|
||||
|
||||
void clearInput() {
|
||||
_fromCurrencyController.clear();
|
||||
_fromAmountController.clear();
|
||||
_toCurrencyController.clear();
|
||||
_toAmountController.clear();
|
||||
}
|
||||
|
||||
void displayResult(String date, String amount, String fromCurrencyCode,
|
||||
double exchangeValue, String toCurrencyCode) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Calculation Results",
|
||||
onWindowTapClose: () {
|
||||
setState(() {
|
||||
_bannerAd = MihBannerAd();
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.currency_exchange,
|
||||
size: 150,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
"Values as at $date",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
amount,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
fromCurrencyCode.toUpperCase(),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
exchangeValue.toStringAsFixed(2),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
toCurrencyCode.toUpperCase(),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
SizedBox(child: _bannerAd),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void displayDisclaimer() {
|
||||
final String companyName = 'Mzansi Innovation Hub';
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Disclaimer Notice",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Main Title
|
||||
|
||||
Text(
|
||||
'Disclaimer of Warranty and Limitation of Liability for Forex Calculator',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24.0),
|
||||
|
||||
// First Paragraph - using RichText to bold "the Tool"
|
||||
_buildRichText(
|
||||
'The Forex Calculator feature ("',
|
||||
'the Tool',
|
||||
'") is provided on an "as is" and "as available" basis. It is an experimental feature and is intended solely for informational and illustrative purposes.',
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
|
||||
// Second Paragraph
|
||||
Text(
|
||||
'$companyName makes no representations or warranties of any kind, express or implied, as to the accuracy, completeness, reliability, or suitability of the information and calculations generated by the Tool. All exchange rates and results are estimates and are subject to change without notice.',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
|
||||
// Third Paragraph
|
||||
Text(
|
||||
'The information provided by the Tool should not be construed as financial, investment, trading, or any other form of advice. You should not make any financial decisions based solely on the output of this Tool. We expressly recommend that you seek independent professional advice and verify all data with a qualified financial advisor and/or through alternative, reliable market data sources before executing any foreign exchange transactions.',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
|
||||
// Fourth Paragraph
|
||||
Text(
|
||||
'By using the Tool, you agree that $companyName, its affiliates, directors, and employees shall not be held liable for any direct, indirect, incidental, special, consequential, or exemplary damages, including but not limited to, damages for loss of profits, goodwill, use, data, or other intangible losses, resulting from: (i) the use or the inability to use the Tool; (ii) any inaccuracies, errors, or omissions in the Tool\'s calculations or data; or (iii) any reliance placed by you on the information provided by the Tool.',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRichText(String start, String bold, String end) {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
children: <TextSpan>[
|
||||
TextSpan(text: start),
|
||||
TextSpan(
|
||||
text: bold, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
TextSpan(text: end),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_fromCurrencyController.dispose();
|
||||
_fromAmountController.dispose();
|
||||
_toCurrencyController.dispose();
|
||||
_toAmountController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
availableCurrencies = MihCurrencyExchangeRateServices.getCurrencyCodeList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem: getBody(screenWidth),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return FutureBuilder(
|
||||
future: availableCurrencies,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Mihloadingcircle();
|
||||
} else if (snapshot.connectionState == ConnectionState.done) {
|
||||
return MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding: MzansiInnovationHub.of(context)!.theme.screenType ==
|
||||
"desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: <Widget>[
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _fromAmountController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Currency Amount",
|
||||
numberMode: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihDropdownField(
|
||||
controller: _fromCurrencyController,
|
||||
hintText: "From",
|
||||
dropdownOptions: snapshot.data!,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
requiredText: true,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihDropdownField(
|
||||
controller: _toCurrencyController,
|
||||
hintText: "To",
|
||||
dropdownOptions: snapshot.data!,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
requiredText: true,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
RichText(
|
||||
textAlign: TextAlign.left,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
const TextSpan(
|
||||
text:
|
||||
"* Experimental Feature: Please review "),
|
||||
TextSpan(
|
||||
text: "Diclaimer",
|
||||
style: TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
displayDisclaimer();
|
||||
},
|
||||
),
|
||||
const TextSpan(text: " before use."),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
submitForm();
|
||||
FocusScope.of(context)
|
||||
.requestFocus(FocusNode());
|
||||
} else {
|
||||
MihAlertServices()
|
||||
.formNotFilledCompletely(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Calculate",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
clearInput();
|
||||
},
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Clear",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling Currency Exchange Data.",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,780 +0,0 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_calendar_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_date_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_time_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_delete_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/appointment.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BuildAppointmentList extends StatefulWidget {
|
||||
final List<Appointment> appointmentList;
|
||||
final AppUser signedInUser;
|
||||
final Business? business;
|
||||
final BusinessUser? businessUser;
|
||||
final bool personalSelected;
|
||||
final bool inWaitingRoom;
|
||||
final TextEditingController titleController;
|
||||
final TextEditingController descriptionIDController;
|
||||
final TextEditingController? patientIdController;
|
||||
final TextEditingController dateController;
|
||||
final TextEditingController timeController;
|
||||
|
||||
const BuildAppointmentList({
|
||||
super.key,
|
||||
required this.appointmentList,
|
||||
required this.signedInUser,
|
||||
required this.business,
|
||||
required this.businessUser,
|
||||
required this.personalSelected,
|
||||
required this.inWaitingRoom,
|
||||
required this.titleController,
|
||||
required this.descriptionIDController,
|
||||
required this.patientIdController,
|
||||
required this.dateController,
|
||||
required this.timeController,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildAppointmentList> createState() => _BuildAppointmentListState();
|
||||
}
|
||||
|
||||
class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
String baseAPI = AppEnviroment.baseApiUrl;
|
||||
TextEditingController patientIdController = TextEditingController();
|
||||
TextEditingController dateController = TextEditingController();
|
||||
TextEditingController timeController = TextEditingController();
|
||||
TextEditingController idController = TextEditingController();
|
||||
TextEditingController fnameController = TextEditingController();
|
||||
TextEditingController lnameController = TextEditingController();
|
||||
TextEditingController daysExtensionController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
int counter = 0;
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
double getPaddingSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
return (width / 10);
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayAppointment(int index, double bodyWidth) {
|
||||
String heading =
|
||||
"${widget.appointmentList[index].date_time.split('T')[1].substring(0, 5)} - ${widget.appointmentList[index].title.toUpperCase()}";
|
||||
String description = widget.appointmentList[index].description;
|
||||
DateTime now = new DateTime.now();
|
||||
int hourNow = int.parse(now.toString().split(' ')[1].substring(0, 2));
|
||||
String date =
|
||||
new DateTime(now.year, now.month, now.day).toString().split(' ')[0];
|
||||
String appointDate = widget.appointmentList[index].date_time.split('T')[0];
|
||||
int appointHour = int.parse(
|
||||
widget.appointmentList[index].date_time.split('T')[1].substring(0, 2));
|
||||
// print("Date Time Now: $now");
|
||||
// print("Hour Now: $hourNow");
|
||||
// print("Date: $date");
|
||||
// print("Appointment Date: $appointDate");
|
||||
// print("Appointment Hour: $appointHour");
|
||||
Color appointmentColor = MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
if (date == appointDate) {
|
||||
if (appointHour < hourNow) {
|
||||
appointmentColor = MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
} else if (appointHour == hourNow) {
|
||||
appointmentColor = MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
}
|
||||
} else if (DateTime.parse(appointDate).isBefore(DateTime.parse(date))) {
|
||||
appointmentColor = MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
}
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 3.0,
|
||||
color: appointmentColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
heading,
|
||||
style: TextStyle(
|
||||
color: appointmentColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
description,
|
||||
style: TextStyle(
|
||||
color: appointmentColor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
widget.titleController.text = widget.appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
widget.appointmentList[index].description;
|
||||
widget.dateController.text =
|
||||
widget.appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text = widget.appointmentList[index].date_time
|
||||
.split('T')[1]
|
||||
.substring(0, 5);
|
||||
});
|
||||
if (widget.inWaitingRoom == false) {
|
||||
appointmentDetailsWindow(index, bodyWidth);
|
||||
} else {
|
||||
waitingRiinAppointmentDetailsWindow(index, bodyWidth);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentDetailsWindow(int index, double bodyWidth) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Appointment Details",
|
||||
menuOptions: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.edit,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Edit Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
appointmentUpdateWindow(index, bodyWidth);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Delete Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
deleteAppointmentConfirmationWindow(index);
|
||||
},
|
||||
),
|
||||
],
|
||||
onWindowTapClose: () {
|
||||
context.pop();
|
||||
widget.dateController.clear();
|
||||
widget.timeController.clear();
|
||||
widget.titleController.clear();
|
||||
widget.descriptionIDController.clear();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.titleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Appointment Title",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.dateController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Date",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.timeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Time",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.descriptionIDController,
|
||||
multiLineInput: true,
|
||||
height: 250,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Appointment Description",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void waitingRiinAppointmentDetailsWindow(int index, double bodyWidth) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Appointment Details",
|
||||
menuOptions: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.edit,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Edit Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
appointmentUpdateWindow(index, bodyWidth);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Delete Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
deleteAppointmentConfirmationWindow(index);
|
||||
},
|
||||
),
|
||||
],
|
||||
onWindowTapClose: () {
|
||||
context.pop();
|
||||
widget.dateController.clear();
|
||||
widget.timeController.clear();
|
||||
widget.titleController.clear();
|
||||
widget.descriptionIDController.clear();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.titleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Appointment Title",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.dateController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Date",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.timeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Time",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.descriptionIDController,
|
||||
multiLineInput: true,
|
||||
height: 250,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Appointment Description",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// SizedBox(
|
||||
// // width: 500,
|
||||
// child: MIHTextField(
|
||||
// controller: widget.titleController,
|
||||
// hintText: "Patient ID Number",
|
||||
// editable: false,
|
||||
// required: false,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentUpdateWindow(int index, double bodyWidth) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Update Appointment",
|
||||
onWindowTapClose: () {
|
||||
setState(() {
|
||||
widget.titleController.text = widget.appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
widget.appointmentList[index].description;
|
||||
widget.dateController.text =
|
||||
widget.appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text = widget
|
||||
.appointmentList[index].date_time
|
||||
.split('T')[1]
|
||||
.substring(0, 5);
|
||||
});
|
||||
context.pop();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: widget.titleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Appointment Title",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihDateField(
|
||||
controller: widget.dateController,
|
||||
labelText: "Date",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTimeField(
|
||||
controller: widget.timeController,
|
||||
labelText: "Time",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: widget.descriptionIDController,
|
||||
multiLineInput: true,
|
||||
height: 250,
|
||||
requiredText: true,
|
||||
hintText: "Appointment Description",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
updateAppointmentCall(index);
|
||||
} else {
|
||||
MihAlertServices()
|
||||
.formNotFilledCompletely(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Update",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
bool isAppointmentInputValid() {
|
||||
if (widget.dateController.text.isEmpty ||
|
||||
widget.timeController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void deleteAppointmentConfirmationWindow(int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MIHDeleteMessage(
|
||||
deleteType: "Appointment",
|
||||
onTap: () {
|
||||
deleteAppointmentCall(index);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateAppointmentCall(int index) async {
|
||||
int statusCode;
|
||||
if (isAppointmentInputValid()) {
|
||||
if (widget.personalSelected == true) {
|
||||
statusCode = await MihMzansiCalendarApis.updatePersonalAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
null,
|
||||
widget.appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
widget.dateController.text,
|
||||
widget.timeController.text,
|
||||
context,
|
||||
);
|
||||
} else if (widget.personalSelected == false &&
|
||||
widget.inWaitingRoom == false) {
|
||||
statusCode = await MihMzansiCalendarApis.updateBusinessAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
widget.appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
widget.dateController.text,
|
||||
widget.timeController.text,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
statusCode = await MihMzansiCalendarApis.updatePatientAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
widget.appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
widget.dateController.text,
|
||||
widget.timeController.text,
|
||||
context,
|
||||
);
|
||||
}
|
||||
if (statusCode == 200) {
|
||||
context.pop();
|
||||
context.pop();
|
||||
if (!widget.inWaitingRoom) {
|
||||
KenLogger.warning("calendar route");
|
||||
context.goNamed(
|
||||
"mihCalendar",
|
||||
extra: CalendarArguments(
|
||||
widget.signedInUser,
|
||||
widget.personalSelected,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
KenLogger.warning("waiting room route");
|
||||
// GoRouter.of(context).refresh();
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: false,
|
||||
);
|
||||
context.goNamed(
|
||||
'patientManager',
|
||||
extra: PatManagerArguments(
|
||||
widget.signedInUser,
|
||||
false,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
),
|
||||
);
|
||||
// context.pop();
|
||||
}
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Input Error");
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteAppointmentCall(int index) async {
|
||||
int statucCode = await MihMzansiCalendarApis.deleteAppointmentAPICall(
|
||||
widget.signedInUser,
|
||||
widget.personalSelected,
|
||||
widget.business,
|
||||
widget.businessUser,
|
||||
widget.inWaitingRoom,
|
||||
widget.appointmentList[index].idappointments,
|
||||
context,
|
||||
);
|
||||
if (statucCode == 200) {
|
||||
context.pop();
|
||||
context.pop();
|
||||
setState(() {
|
||||
widget.appointmentList.removeAt(index);
|
||||
});
|
||||
successPopUp("Successfully Deleted Appointment",
|
||||
"You appointment has been successfully deleted from your calendar.");
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageAlert(
|
||||
alertIcon: Icon(
|
||||
Icons.check_circle_outline_rounded,
|
||||
size: 150,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
alertTitle: title,
|
||||
alertBody: Column(
|
||||
children: [
|
||||
Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
alertColour: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void internetConnectionPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(
|
||||
errorType: "Internet Connection",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
bool canEditAppointment(int index) {
|
||||
if (widget.personalSelected == true &&
|
||||
widget.appointmentList[index].app_id == widget.signedInUser.app_id &&
|
||||
widget.appointmentList[index].business_id == "") {
|
||||
return true;
|
||||
} else if (widget.personalSelected == false &&
|
||||
widget.appointmentList[index].business_id ==
|
||||
widget.business!.business_id &&
|
||||
widget.appointmentList[index].app_id.isEmpty) {
|
||||
return true;
|
||||
} else if (widget.personalSelected == false &&
|
||||
widget.appointmentList[index].business_id ==
|
||||
widget.business!.business_id &&
|
||||
widget.appointmentList[index].app_id.isNotEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
daysExtensionController.dispose();
|
||||
dateController.dispose();
|
||||
timeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
setState(() {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
});
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: getPaddingSize()),
|
||||
child: ListView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: widget.appointmentList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return displayAppointment(index, width);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/package_tools/appointments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MzansiCalendar extends StatefulWidget {
|
||||
final CalendarArguments arguments;
|
||||
const MzansiCalendar({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MzansiCalendar> createState() => _MzansiCalendarState();
|
||||
}
|
||||
|
||||
class _MzansiCalendarState extends State<MzansiCalendar> {
|
||||
int _selcetedIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
print("Index: $_selcetedIndex");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
// Navigator.of(context).pop();
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: widget.arguments.personalSelected,
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.calendar_month)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
};
|
||||
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
//appointment here
|
||||
Appointments(
|
||||
signedInUser: widget.arguments.signedInUser,
|
||||
business: widget.arguments.business,
|
||||
businessUser: widget.arguments.businessUser,
|
||||
personalSelected: widget.arguments.personalSelected,
|
||||
),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
widget.arguments.personalSelected == true ? "Personal" : "Business",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MzansiCalendarTile extends StatefulWidget {
|
||||
final CalendarArguments arguments;
|
||||
final double packageSize;
|
||||
|
||||
const MzansiCalendarTile({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MzansiCalendarTile> createState() => _MzansiCalendarTileState();
|
||||
}
|
||||
|
||||
class _MzansiCalendarTileState extends State<MzansiCalendarTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mihCalendar",
|
||||
extra: widget.arguments,
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/calendar',
|
||||
// arguments: widget.arguments,
|
||||
// );
|
||||
},
|
||||
appName: "Calendar",
|
||||
appIcon: Icon(
|
||||
MihIcons.calendar,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: widget.packageSize,
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
primaryColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,550 +0,0 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_calendar_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_date_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_time_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/appointment.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/builder/build_appointment_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../main.dart';
|
||||
|
||||
import '../../../mih_components/mih_package_components/mih_calendar.dart';
|
||||
import '../../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import '../../../mih_config/mih_env.dart';
|
||||
import '../../../mih_components/mih_objects/app_user.dart';
|
||||
|
||||
class Appointments extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final Business? business;
|
||||
final BusinessUser? businessUser;
|
||||
final bool personalSelected;
|
||||
|
||||
const Appointments({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
required this.business,
|
||||
required this.businessUser,
|
||||
required this.personalSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
State<Appointments> createState() => _PatientAccessRequestState();
|
||||
}
|
||||
|
||||
class _PatientAccessRequestState extends State<Appointments> {
|
||||
TextEditingController selectedAppointmentDateController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentTitleController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentDescriptionIDController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentDateController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentTimeController =
|
||||
TextEditingController();
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
String selectedDay = DateTime.now().toString().split(" ")[0];
|
||||
|
||||
late Future<List<Appointment>> personalAppointmentResults;
|
||||
late Future<List<Appointment>> businessAppointmentResults;
|
||||
late Future<List<Appointment>> appointmentResults;
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
Widget displayAppointmentList(List<Appointment> appointmentList) {
|
||||
if (appointmentList.isNotEmpty) {
|
||||
return Expanded(
|
||||
child: BuildAppointmentList(
|
||||
appointmentList: appointmentList,
|
||||
signedInUser: widget.signedInUser,
|
||||
business: widget.business,
|
||||
businessUser: widget.businessUser,
|
||||
personalSelected: widget.personalSelected,
|
||||
inWaitingRoom: false,
|
||||
titleController: _appointmentTitleController,
|
||||
descriptionIDController: _appointmentDescriptionIDController,
|
||||
patientIdController: null,
|
||||
dateController: _appointmentDateController,
|
||||
timeController: _appointmentTimeController,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.calendar,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No appointments for $selectedDay",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.menu,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
" to add an appointment or select a different date"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void addAppointmentWindow(double width) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Add Appointment",
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
_appointmentDateController.clear();
|
||||
_appointmentTimeController.clear();
|
||||
_appointmentTitleController.clear();
|
||||
_appointmentDescriptionIDController.clear();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _appointmentTitleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Appointment Title",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihDateField(
|
||||
controller: _appointmentDateController,
|
||||
labelText: "Date",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTimeField(
|
||||
controller: _appointmentTimeController,
|
||||
labelText: "Time",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _appointmentDescriptionIDController,
|
||||
multiLineInput: true,
|
||||
height: 250,
|
||||
requiredText: true,
|
||||
hintText: "Appointment Description",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
addAppointmentCall();
|
||||
} else {
|
||||
MihAlertServices().formNotFilledCompletely(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Add",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
bool isAppointmentInputValid() {
|
||||
if (_appointmentTitleController.text.isEmpty ||
|
||||
_appointmentDescriptionIDController.text.isEmpty ||
|
||||
_appointmentDateController.text.isEmpty ||
|
||||
_appointmentTimeController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addAppointmentCall() async {
|
||||
if (isAppointmentInputValid()) {
|
||||
int statusCode;
|
||||
if (widget.personalSelected == false) {
|
||||
statusCode = await MihMzansiCalendarApis.addBusinessAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business!,
|
||||
widget.businessUser!,
|
||||
false,
|
||||
_appointmentTitleController.text,
|
||||
_appointmentDescriptionIDController.text,
|
||||
_appointmentDateController.text,
|
||||
_appointmentTimeController.text,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
statusCode = await MihMzansiCalendarApis.addPersonalAppointment(
|
||||
widget.signedInUser,
|
||||
_appointmentTitleController.text,
|
||||
_appointmentDescriptionIDController.text,
|
||||
_appointmentDateController.text,
|
||||
_appointmentTimeController.text,
|
||||
context,
|
||||
);
|
||||
}
|
||||
if (statusCode == 201) {
|
||||
context.pop();
|
||||
successPopUp("Successfully Added Appointment",
|
||||
"You appointment has been successfully added to your calendar.");
|
||||
setState(() {
|
||||
if (widget.personalSelected) {
|
||||
appointmentResults = MihMzansiCalendarApis.getPersonalAppointments(
|
||||
widget.signedInUser.app_id,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Input Error");
|
||||
},
|
||||
);
|
||||
}
|
||||
checkforchange();
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageAlert(
|
||||
alertIcon: Icon(
|
||||
Icons.check_circle_outline_rounded,
|
||||
size: 150,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
alertTitle: title,
|
||||
alertBody: Column(
|
||||
children: [
|
||||
Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
setState(() {
|
||||
_appointmentDateController.clear();
|
||||
_appointmentTimeController.clear();
|
||||
_appointmentTitleController.clear();
|
||||
_appointmentDescriptionIDController.clear();
|
||||
});
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
alertColour: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void internetConnectionPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(
|
||||
errorType: "Internet Connection",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
if (widget.personalSelected == false) {
|
||||
return "Business Appointments";
|
||||
} else {
|
||||
return "Personal Appointments";
|
||||
}
|
||||
}
|
||||
|
||||
void checkforchange() {
|
||||
setState(() {
|
||||
if (widget.personalSelected == false) {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
appointmentResults = MihMzansiCalendarApis.getPersonalAppointments(
|
||||
widget.signedInUser.app_id,
|
||||
selectedDay,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
MIHCalendar(
|
||||
calendarWidth: 500,
|
||||
rowHeight: 35,
|
||||
setDate: (value) {
|
||||
setState(() {
|
||||
selectedDay = value;
|
||||
selectedAppointmentDateController.text = selectedDay;
|
||||
});
|
||||
}),
|
||||
// Divider(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: appointmentResults,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
return const Expanded(
|
||||
child: Center(child: Mihloadingcircle()));
|
||||
} else if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
return displayAppointmentList(snapshot.requireData);
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling appointments",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Add Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
addAppointmentWindow(width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
selectedAppointmentDateController.dispose();
|
||||
_appointmentDateController.dispose();
|
||||
_appointmentTimeController.dispose();
|
||||
_appointmentTitleController.dispose();
|
||||
_appointmentDescriptionIDController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
selectedAppointmentDateController.addListener(checkforchange);
|
||||
setState(() {
|
||||
if (widget.personalSelected == false) {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
appointmentResults = MihMzansiCalendarApis.getPersonalAppointments(
|
||||
widget.signedInUser.app_id,
|
||||
selectedDay,
|
||||
);
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
bodyItem: getBody(screenWidth),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mih_authentication/package_tools/mih_register.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mih_authentication/package_tools/mih_sign_in.dart';
|
||||
|
||||
class MihAuthentication extends StatefulWidget {
|
||||
const MihAuthentication({super.key});
|
||||
|
||||
@override
|
||||
State<MihAuthentication> createState() => _MihAuthenticationState();
|
||||
}
|
||||
|
||||
class _MihAuthenticationState extends State<MihAuthentication> {
|
||||
int _selcetedIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
MihSignIn(
|
||||
onNewUserButtonTap: () {
|
||||
setState(() {
|
||||
_selcetedIndex = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
MihRegister(onExistingUserButtonTap: () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
})
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.perm_identity)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
};
|
||||
temp[const Icon(Icons.create)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 1;
|
||||
});
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
);
|
||||
}
|
||||
|
||||
Widget getAction() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 5.0),
|
||||
child: MihPackageAction(
|
||||
icon: const Icon(MihIcons.mihLogo),
|
||||
iconSize: 45,
|
||||
onTap: () {
|
||||
context.goNamed("aboutMih", extra: 0);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,295 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_authentication_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
|
||||
class MihForgotPassword extends StatefulWidget {
|
||||
const MihForgotPassword({super.key});
|
||||
|
||||
@override
|
||||
State<MihForgotPassword> createState() => _MihForgotPasswordState();
|
||||
}
|
||||
|
||||
class _MihForgotPasswordState extends State<MihForgotPassword> {
|
||||
final emailController = TextEditingController();
|
||||
bool successfulForgotPassword = false;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
bool acceptWarning = false;
|
||||
|
||||
Future<void> submitPasswodReset() async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
try {
|
||||
var resetPassEmailSent = await MihAuthenticationServices()
|
||||
.forgotPassword(emailController.text);
|
||||
context.pop();
|
||||
if (resetPassEmailSent) {
|
||||
setState(() {
|
||||
successfulForgotPassword = true;
|
||||
});
|
||||
}
|
||||
} on Exception {
|
||||
//loginError();
|
||||
}
|
||||
}
|
||||
|
||||
void prePassResteWarning() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageAlert(
|
||||
alertIcon: Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: 100,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
alertTitle: "Password Reset Confirmation",
|
||||
alertBody: Column(
|
||||
//mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||
child: Text(
|
||||
"Before you reset your password, please be aware that you'll receive an email with a link to confirm your identity and set a new password. Make sure to check your inbox, including spam or junk folders. If you don't receive the email within a few minutes, please try resending the reset request.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
acceptWarning = true;
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
validateInput();
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Continue",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
alertColour: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void resetLinkSentSuccessfully() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageAlert(
|
||||
alertIcon: Icon(
|
||||
Icons.check_circle_outline_rounded,
|
||||
size: 150,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
alertTitle: "Successfully Sent Reset Link",
|
||||
alertBody: Column(
|
||||
children: [
|
||||
Text(
|
||||
"We've sent a password reset link to your email address. Please check your inbox, including spam or junk folders.\n\nOnce you find the email, click on the link to reset your password.\n\nIf you don't receive the email within a few minutes, please try resending the reset request.\n\nThe reset link will expire after 2 hours",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: true,
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
alertColour: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
// return const MIHSuccessMessage(
|
||||
// successType: "Success",
|
||||
// successMessage:
|
||||
// "We've sent a password reset link to your email address. Please check your inbox, including spam or junk folders.\n\nOnce you find the email, click on the link to reset your password.\n\nIf you don't receive the email within a few minutes, please try resending the reset request.\n\nThe reset link will expire after 2 hours");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void validateInput() async {
|
||||
if (emailController.text.isEmpty) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Input Error");
|
||||
},
|
||||
);
|
||||
} else {
|
||||
await submitPasswodReset();
|
||||
if (successfulForgotPassword) {
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
|
||||
resetLinkSentSuccessfully();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
bodyItem: getBody(screenWidth),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return KeyboardListener(
|
||||
focusNode: _focusNode,
|
||||
autofocus: true,
|
||||
onKeyEvent: (event) async {
|
||||
if (event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.enter) {
|
||||
validateInput();
|
||||
}
|
||||
},
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Padding(
|
||||
padding: MzansiInnovationHub.of(context)!.theme.screenType ==
|
||||
"desktop"
|
||||
? EdgeInsets.symmetric(vertical: 25, horizontal: width * 0.2)
|
||||
: EdgeInsets.symmetric(vertical: 25, horizontal: width * 0.075),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
//logo
|
||||
Icon(
|
||||
Icons.lock,
|
||||
size: 100,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
//Heading
|
||||
Text(
|
||||
'Forgot Password',
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: emailController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Email",
|
||||
validator: (value) {
|
||||
return MihValidationServices().validateEmail(value);
|
||||
},
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 20),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
prePassResteWarning();
|
||||
} else {
|
||||
MihAlertServices().formNotFilledCompletely(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Reset Password",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_authentication_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
|
||||
class MihResetPassword extends StatefulWidget {
|
||||
final String token;
|
||||
const MihResetPassword({
|
||||
super.key,
|
||||
required this.token,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihResetPassword> createState() => _MihResetPasswordState();
|
||||
}
|
||||
|
||||
class _MihResetPasswordState extends State<MihResetPassword> {
|
||||
final passwordController = TextEditingController();
|
||||
final confirmPasswordController = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
void submitFormInput() async {
|
||||
if (passwordController.text != confirmPasswordController.text) {
|
||||
passwordError();
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
bool successfulResetPassword = await MihAuthenticationServices()
|
||||
.resetPassword(widget.token, passwordController.text);
|
||||
context.pop();
|
||||
if (successfulResetPassword) {
|
||||
resetSuccessfully();
|
||||
} else {
|
||||
loginError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resetSuccessfully() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihPackageAlert(
|
||||
alertIcon: Icon(
|
||||
Icons.check_circle_outline_rounded,
|
||||
size: 150,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
alertTitle: "Successfully Reset Password",
|
||||
alertBody: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Great news! Your password reset is complete. You can now log in to Mzansi Innovation Hub using your new password.",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
extra: true,
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
alertColour: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
// return const MIHSuccessMessage(
|
||||
// successType: "Success",
|
||||
// successMessage:
|
||||
// "We've sent a password reset link to your email address. Please check your inbox, including spam or junk folders.\n\nOnce you find the email, click on the link to reset your password.\n\nIf you don't receive the email within a few minutes, please try resending the reset request.\n\nThe reset link will expire after 2 hours");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void loginError() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Invalid Credentials");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void passwordError() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(errorType: "Password Match");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
bodyItem: getBody(screenWidth),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return KeyboardListener(
|
||||
focusNode: _focusNode,
|
||||
autofocus: true,
|
||||
onKeyEvent: (event) async {
|
||||
if (event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.enter) {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
submitFormInput();
|
||||
} else {
|
||||
MihAlertServices().formNotFilledCompletely(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Token: ${widget.token}"), // For testing purposes only
|
||||
//logo
|
||||
Icon(
|
||||
Icons.lock,
|
||||
size: 100,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
//Heading
|
||||
Text(
|
||||
'Reset Password',
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 25),
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: passwordController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Password",
|
||||
passwordMode: true,
|
||||
autofillHints: const [AutofillHints.password],
|
||||
validator: (value) {
|
||||
return MihValidationServices().validatePassword(value);
|
||||
},
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: confirmPasswordController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Confirm Password",
|
||||
passwordMode: true,
|
||||
autofillHints: const [AutofillHints.password],
|
||||
validator: (value) {
|
||||
return MihValidationServices().validatePassword(value);
|
||||
},
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 25),
|
||||
// sign in button
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
submitFormInput();
|
||||
} else {
|
||||
MihAlertServices().formNotFilledCompletely(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Reset Password",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||