153 Commits

Author SHA1 Message Date
971623af77 Merge pull request 'Linux Flatpak config set up' (#26) from V.1.2.6 into main
Reviewed-on: #26
2026-02-26 13:21:15 +00:00
84cb6b2e83 linux icon image fix 2026-02-26 15:15:49 +02:00
6e07a55885 Flatpak linux build 2026-02-26 13:54:38 +02:00
8fb31695a8 linux flatpak config pt11 2026-02-26 12:34:01 +02:00
4fafa35888 linux flatpak config pt10 2026-02-26 12:17:14 +02:00
0cf9634c5d linux flatpak config pt9 2026-02-26 12:15:59 +02:00
787a8057b2 linux flatpak config pt8 2026-02-26 12:15:04 +02:00
5f911d51f9 linux flatpak config pt7 2026-02-26 09:31:20 +02:00
8da29792b4 linux flatpak config pt6 2026-02-26 09:28:18 +02:00
fd4c34c59d Merge pull request 'linux flatpak config pt5' (#25) from V.1.2.6 into main
Reviewed-on: #25
2026-02-25 13:50:19 +00:00
5e003a4d71 linux flatpak config pt5 2026-02-25 15:50:02 +02:00
dca595bf60 Merge pull request 'linux flatpak config pt4' (#24) from V.1.2.6 into main
Reviewed-on: #24
2026-02-25 13:44:37 +00:00
fcf1bbbb15 linux flatpak config pt4 2026-02-25 15:44:10 +02:00
8a0c0d7dba Merge pull request 'linux flatpak config pt3' (#23) from V.1.2.6 into main
Reviewed-on: #23
2026-02-25 13:36:22 +00:00
ff7f363983 linux flatpak config pt3 2026-02-25 15:35:45 +02:00
a54f1c61ae Merge pull request 'linux flatpak config pt2' (#22) from V.1.2.6 into main
Reviewed-on: #22
2026-02-25 13:10:05 +00:00
843997e58c linux flatpak config pt2 2026-02-25 15:09:23 +02:00
cbe70e2e44 Merge pull request 'linux flatpak config' (#21) from V.1.2.6 into main
Reviewed-on: #21
2026-02-25 12:52:15 +00:00
3778ebb261 linux flatpak config 2026-02-25 14:51:15 +02:00
c911e88453 Merge pull request 'linux name change' (#20) from V.1.2.6 into main
Reviewed-on: #20
2026-02-25 11:59:39 +00:00
b1487839a7 linux name change 2026-02-25 13:58:42 +02:00
518dd1300e Merge pull request 'fix platform specific code not working on web pt2' (#19) from V.1.2.6 into main
Reviewed-on: #19
2026-02-25 10:19:05 +00:00
221030eff3 fix platform specific code not working on web pt2 2026-02-25 12:16:53 +02:00
707b49c088 Merge pull request 'fix platform specific code not working on web' (#18) from V.1.2.6 into main
Reviewed-on: #18
2026-02-25 10:05:42 +00:00
5135629b33 fix platform specific code not working on web 2026-02-25 12:05:07 +02:00
bb64be077f Merge pull request 'api cros fix' (#17) from V.1.2.6 into main
Reviewed-on: #17
2026-02-25 09:55:54 +00:00
281ea863e8 api cros fix 2026-02-25 11:54:49 +02:00
64af64f28b Merge pull request 'V.1.2.6' (#16) from V.1.2.6 into main
Reviewed-on: #16
2026-02-25 09:30:49 +00:00
1c0dd6d328 update build number to 130 2026-02-25 10:25:28 +02:00
07d4ba4afa Support linux version of MIHpt2 2026-02-24 16:30:06 +02:00
6ad6b6ccbd Support linux version of MIH 2026-02-24 15:41:55 +02:00
ce2575035f make profile picture the full height of the window 2026-02-24 12:43:34 +02:00
baea2c9fdb fix file display on Dev Web & iOS 2026-02-24 12:37:31 +02:00
27639cb964 add scroll bar to dropdown fields 2026-02-24 11:05:24 +02:00
1143d11054 fix supertoken versioning error 2026-02-24 11:02:30 +02:00
213f3d418d update build number to 129 2026-02-18 15:41:37 +02:00
e33a62b909 update look & feel of attribution list 2026-02-18 14:03:04 +02:00
ebab9bae52 update build no to 128 2026-02-18 11:52:30 +02:00
82c25c5406 make profile picture expandable 2026-02-18 11:51:44 +02:00
3f0fc08a5c update business user edit workflow 2026-02-18 10:56:34 +02:00
f137ea41ac fix loading indicator alignment for business QR code 2026-02-18 10:41:49 +02:00
a7effa3576 Update profile link and business card Icons alignment 2026-02-18 10:26:41 +02:00
74341a9cc6 Enhance Mzansi Profile Look & Feel and workflow 2026-02-18 10:18:03 +02:00
c5267c0540 change follow us link alignments 2026-02-16 16:27:39 +02:00
d4ba3aaa03 fix short cut icon issue 2026-02-16 15:34:27 +02:00
103ccdc022 Add scroll bar to mih 2026-02-16 15:23:16 +02:00
f8a722eb50 change design on profile links and add git option 2026-02-16 14:43:34 +02:00
fdb28080e3 fix web cros issues with fixed dev port pt2 2026-02-16 14:42:33 +02:00
8a384921c5 fix web cros issues with fixed dev port 2026-02-16 14:41:51 +02:00
4b47bf5288 enhacne install/ update mih button to cater for huawei 2026-02-16 14:08:00 +02:00
141611b84d fix mzansi ai modal 2026-02-16 13:43:15 +02:00
a29d0afeb8 update version number of mih 2026-02-16 13:25:46 +02:00
eb93714022 add ds_store file to ingore file 2026-02-16 13:09:33 +02:00
071612a521 BUG: API Wildcard CROS issue 2026-02-16 13:09:33 +02:00
726a60ad25 BUG: Fix exposed ports on mih server 2026-02-16 13:09:33 +02:00
b897986c1f BUG: Fix hardcoded supertoken api key 2026-02-16 13:09:33 +02:00
7d4d7fc713 BUG: Fix Security Flutter Web server 2026-02-16 13:09:33 +02:00
91075255f4 add scrolling to about package 2026-02-10 14:07:05 +02:00
5c2f19dcc4 enable linux platform & rename widnow 2026-02-10 11:58:35 +02:00
58aebbeabe Merge pull request 'ruleset test' (#1) from tester-branch into main
Reviewed-on: #1
2026-02-04 11:18:21 +00:00
670480910b ruleset test 2026-02-04 13:16:15 +02:00
45c1b247d3 testing 2026-02-04 13:13:21 +02:00
yaso-meth
ecd24670e9 Simplify MIH Server start/stop instructions 2026-02-03 16:43:46 +02:00
yaso-meth
ab99518ff2 Fix directory name in README for navigation 2026-02-03 16:41:39 +02:00
yaso-meth
6ac6aff59e Update directory name in README for navigation 2026-02-03 16:40:59 +02:00
33ca7b613e remove old nginx 2026-02-03 16:31:10 +02:00
yaso-meth
e83b0b50ae Merge pull request #265 from yaso-meth/yaso-meth-patch-1
Update README with Gitea and WordPress SQL config
2026-02-03 16:19:38 +02:00
yaso-meth
bcd19de256 Update README with Gitea and WordPress SQL config
Add database configuration variables for Gitea and WordPress.
2026-02-03 16:18:48 +02:00
yaso-meth
ae36879ec5 Revise title and add introduction in README
Updated project title and added introductory text.
2026-02-03 16:15:41 +02:00
yaso-meth
eda609cf7e Update license information for the MIH Project 2026-02-03 15:46:42 +02:00
yaso-meth
e1744b09e3 Merge pull request #264 from yaso-meth/V.1.2.5
V.1.2.5
2026-02-03 14:01:14 +02:00
a3845df8bd Merge branch 'main' into V.1.2.5 2026-02-03 13:57:15 +02:00
d7eebe152b test file 2026-02-03 13:52:47 +02:00
d8a807b43e update build to 1.2.5+1.2.6 2026-02-03 13:29:20 +02:00
5172017a54 Update MZansi AI prod Model 2026-02-03 13:26:37 +02:00
535924691e NEW: Add Mzansi Directory Shortcut 2026-02-03 13:26:17 +02:00
ca8e0f56ac Remove women4change info and revert colors 2026-02-03 10:17:56 +02:00
63071325cb favourite business load fix 2026-02-03 10:15:07 +02:00
800cd635c2 Remove profile link from personal profile for now 2026-02-03 10:05:00 +02:00
f46ce36861 linux app config 2026-02-03 09:57:38 +02:00
b69fd92b19 Update docker compose file for new architechure 2026-01-29 13:02:24 +02:00
9e19dc0fa4 Update API files for new architechure 2026-01-29 13:02:05 +02:00
38c40e2dfe Update launch file for new architechure 2026-01-29 13:01:41 +02:00
02bbc32d23 Update ignore file for new architechure 2026-01-29 13:01:28 +02:00
5b052a1fa9 rename container folders 2026-01-29 11:11:45 +02:00
d5349d981c update architecture 2026-01-29 11:11:25 +02:00
d6c28b631a ignore new mih_minio 2026-01-29 11:07:50 +02:00
74c5276c94 remove old database ignore 2026-01-29 11:06:01 +02:00
d5e349d218 ignore new db folder 2026-01-29 11:04:53 +02:00
44527c8f10 Add self hosted GIT plaform 2026-01-29 10:08:44 +02:00
fbb9d8573c pat man loading 2026-01-06 16:49:32 +02:00
010fc0bc74 BUG: file viewer opening bug 2025-12-17 20:12:51 +02:00
45ac3f03e6 BUG: Supertokens api fix 2025-12-14 23:36:11 +02:00
eea3248525 NEW: MIH Profile Links pt1 2025-12-11 12:57:12 +02:00
b945a34ad4 BUG: Profile set up bug 2025-12-10 19:42:55 +02:00
e3ac1be71c BUG: Business Profile Vew pt2 2025-12-10 12:52:31 +02:00
3a955e67ef BUG: Business Profile Vew 2025-12-10 12:52:13 +02:00
777043e2ca NEW: Config firebase Cloud Messaging for Notifications 2025-12-10 10:18:57 +02:00
6a8b9c6902 QOL: Package Tile Update 2025-12-09 19:14:50 +02:00
07360dd308 QOL: only get user data if user is null 2025-12-09 11:46:16 +02:00
7c59e2a5c8 NEW: New python package added to requirements 2025-12-09 10:54:33 +02:00
0b57e10532 QOL: Button alignment 2025-12-08 19:46:21 +02:00
5681c6d73b BUG: Patient Manager Data fix pt2 2025-12-04 09:19:30 +02:00
f44ff6443c BUG: Patient Manager Data fix 2025-12-03 22:01:49 +02:00
fe5b61f6bc QOL: Switch from Network Image to CachedNetworkImage 2025-12-03 21:42:42 +02:00
e7729a8ce8 QOL: About MIH Share button update 2025-12-03 21:35:41 +02:00
227a2f7ae7 update buiold to 125 2025-12-03 21:09:22 +02:00
f26c1eb01a QOL: Mzansi Ai LLM detection 2025-12-03 12:31:21 +02:00
ca0f13a6df build number update to 124 2025-12-03 11:40:29 +02:00
021a25f50c QOL: Data display load minesweeper pt1 2025-12-03 11:26:47 +02:00
0a9f0c000e QOL: Data display load Mzansi Direct pt4 2025-12-03 11:16:24 +02:00
3ff670886c QOL: Data display load Mzansi Direct pt3 2025-12-03 11:08:22 +02:00
a6d5e4ad35 QOL: Data display load Mzansi Direct pt2 2025-12-03 10:51:18 +02:00
456dff6402 QOL: Data display load Mzansi Direct pt1 2025-12-03 10:32:03 +02:00
d3fdc83373 BUG: incorrect code display style 2025-12-03 09:21:15 +02:00
8704d4dd64 BUG: Patient Infor Scrolling 2025-12-02 19:20:24 +02:00
37920466ac Update build to 123 2025-12-01 10:51:01 +02:00
56d54a3711 QOL: Calanedar message alingment 2025-12-01 10:49:14 +02:00
aef501cd25 QOL: Cache leaderboard images 2025-12-01 10:40:29 +02:00
4f5761271c QOL: Mzansi AI Suggestion update 2025-12-01 10:37:57 +02:00
252e120b99 BUG: Business Team list view 2025-12-01 10:36:25 +02:00
b5c26c3e43 BUG: Mzansi Directory person search on person press 2025-12-01 10:32:26 +02:00
74be2fc559 BUG: File list icons 2025-12-01 10:29:02 +02:00
b519b99a91 QOL: Mzansi Home Scroll 2025-12-01 10:26:17 +02:00
72261af7b9 build number update to 122 2025-11-28 13:49:02 +02:00
ad96725478 QOL: Mzansi Profile Package performance improvements pt2 2025-11-28 13:48:25 +02:00
ef4c3102a9 QOL: MIH Authentication Package performance improvements 2025-11-28 13:43:51 +02:00
9a75bcc810 QOL: MIH Access Controls Package performance improvements pt2 2025-11-28 13:38:14 +02:00
586e67b369 QOL: MIH Mine Sweeper Package performance improvements pt2 2025-11-28 13:30:12 +02:00
e8cae1a894 QOL: MIH Calendar Package performance improvements pt2 2025-11-28 13:26:32 +02:00
cd8115c597 QOL: Patient Manager Package performance improvements pt2 2025-11-28 13:22:54 +02:00
730c5d2bdf QOL: MIH Package performance improvements pt2 2025-11-28 13:13:27 +02:00
cea8ccab5a QOL: Mzansi Wallet Package performance improvements pt2 2025-11-28 13:02:34 +02:00
4f168c5b0e QOL: MIH About Package performance improvements 2025-11-28 12:57:19 +02:00
99f8b1a3f9 QOL: MIH Access Controls Package performance improvements 2025-11-28 12:54:31 +02:00
30c06261c8 QOL: MIH Mine Sweeper Package performance improvements 2025-11-28 12:52:33 +02:00
c843c0a55d QOL: MIH Calculator Package performance improvements 2025-11-28 12:47:44 +02:00
94ac83db9e QOL: Mzansi AI Package performance improvements 2025-11-28 12:44:51 +02:00
a3b8da5357 QOL: MIH Calendar Package performance improvements 2025-11-28 12:43:07 +02:00
47bc23c029 QOL: Patient Manager Package performance improvements 2025-11-28 12:41:30 +02:00
c16d8b6e91 QOL: Mzansi Wallet Package performance improvements 2025-11-28 12:31:39 +02:00
a6fe4499d0 QOL: Mzansi Profile Package performance improvements 2025-11-28 12:29:09 +02:00
004c2397c5 QOL: MIH Home Package performance improvements 2025-11-28 12:15:12 +02:00
d64193d1f8 QOL: MIH Package performance improvements 2025-11-28 12:14:20 +02:00
e330875c6f build update to 121 2025-11-28 11:43:38 +02:00
3d2addf1d6 BUG: fav bus view fix performace pt 2 2025-11-28 11:33:26 +02:00
3b6e1d22ec build update to 120 2025-11-28 10:30:33 +02:00
ff913c0c54 BUG: fav bus view fix 2025-11-28 10:26:36 +02:00
c45c933277 Update version and build 2025-11-27 13:16:30 +02:00
89d6999abf BUG: patient profile picture in patient manager 2025-11-27 13:14:40 +02:00
969ecf8fdc BUG: User search piture load 2025-11-27 12:57:15 +02:00
ee7d3881e6 BUG: Image loading of businesses 2025-11-27 12:40:34 +02:00
cc3f18f7e2 QOL: Mzansi AI Enhancement pt1 2025-11-27 09:48:42 +02:00
728 changed files with 9608 additions and 6659 deletions

BIN
.DS_Store vendored

Binary file not shown.

18
.gitignore vendored
View File

@@ -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
View File

@@ -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",

View File

@@ -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'

View File

@@ -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"]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#6641b2</color>
<!-- Women For Change -->
<color name="mih_icon_background">#6641b2</color>
<color name="mih_icon_foreground">#E0D1FF</color>
<!-- Original -->
<!-- <color name="mih_icon_background">#3A4454</color>
<color name="mih_icon_foreground">#bedcfe</color> -->
</resources>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

View File

@@ -1,321 +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.4";
// 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"),
),
// Text selection / cursor color
textSelectionTheme: TextSelectionThemeData(
cursorColor: MihColors.getPrimaryColor(mode == "Dark"),
selectionColor:
MihColors.getPrimaryColor(mode == "Dark").withOpacity(0.25),
selectionHandleColor: MihColors.getPrimaryColor(mode == "Dark"),
),
tooltipTheme: TooltipThemeData(
decoration: BoxDecoration(
color: MihColors.getSecondaryColor(mode == "Dark"),
borderRadius: BorderRadius.circular(6),
border: Border.all(
width: 1.0,
color: MihColors.getPrimaryColor(mode == "Dark"),
),
boxShadow: [
BoxShadow(
color:
MihColors.getPrimaryColor(mode == "Dark").withOpacity(0.18),
blurRadius: 6,
offset: const Offset(0, 2),
),
],
),
textStyle: TextStyle(
color: MihColors.getPrimaryColor(mode == "Dark"),
fontSize: 13,
height: 1.2,
),
waitDuration: const Duration(milliseconds: 500),
showDuration: const Duration(seconds: 3),
preferBelow: true,
verticalOffset: 24,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
triggerMode: TooltipTriggerMode.longPress,
),
// // Input decoration (text fields) theme
// inputDecorationTheme: InputDecorationTheme(
// filled: true,
// fillColor: mode == "Dark"
// ? MihColors.getPrimaryColor(true).withOpacity(0.06)
// : MihColors.getPrimaryColor(false).withOpacity(0.03),
// contentPadding:
// const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(8),
// borderSide:
// BorderSide(color: MihColors.getSecondaryColor(mode == "Dark")),
// ),
// enabledBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(8),
// borderSide: BorderSide(
// color:
// MihColors.getSecondaryColor(mode == "Dark").withOpacity(0.6)),
// ),
// focusedBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(8),
// borderSide: BorderSide(
// color: MihColors.getSecondaryColor(mode == "Dark"), width: 2),
// ),
// hintStyle: TextStyle(
// color:
// MihColors.getSecondaryColor(mode == "Dark").withOpacity(0.7)),
// labelStyle:
// TextStyle(color: MihColors.getSecondaryColor(mode == "Dark")),
// errorStyle: TextStyle(color: MihColors.getRedColor(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_package_components/assets/images/loading_light.gif',
// );
// } else {
// loading = const AssetImage(
// 'lib/mih_package_components/assets/images/loading_dark.gif',
// );
// }
// return loading;
// }
// AssetImage altLoadingImage() {
// if (mode == "Dark") {
// loading = const AssetImage(
// 'lib/mih_package_components/assets/images/loading_dark.gif',
// );
// } else {
// loading = const AssetImage(
// 'lib/mih_package_components/assets/images/loading_light.gif',
// );
// }
// return loading;
// }
// String loadingImageLocation() {
// if (mode == "Dark") {
// loadingAssetText =
// 'lib/mih_package_components/assets/images/loading_light.gif';
// } else {
// loadingAssetText =
// 'lib/mih_package_components/assets/images/loading_dark.gif';
// }
// return loadingAssetText;
// }
// String altLoadingImageLocation() {
// if (mode == "Dark") {
// loadingAssetText =
// 'lib/mih_package_components/assets/images/loading_dark.gif';
// } else {
// loadingAssetText =
// 'lib/mih_package_components/assets/images/loading_light.gif';
// }
// return loadingAssetText;
// }
// AssetImage aiLogoImage() {
// if (mode == "Dark") {
// return const AssetImage(
// 'lib/mih_package_components/assets/images/mzansi_ai-dark.png',
// );
// } else {
// return const AssetImage(
// 'lib/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);
// }
}

View File

@@ -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_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_package_components/assets/images/i-dont-know-light.png');
// } else {
// print("here in dark icon");
// return const AssetImage(
// 'lib/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("Here Error: $e");
}
},
icon: Icon(
Icons.edit,
),
),
),
),
],
),
);
}
}

View File

@@ -1,248 +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;
final Function(String?)? onSelected;
const MihDropdownField({
super.key,
required this.controller,
required this.hintText,
required this.dropdownOptions,
required this.requiredText,
required this.editable,
required this.enableSearch,
this.validator,
this.onSelected,
});
@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: widget.enableSearch
? TextInputAction.search
: TextInputAction.none,
requestFocusOnTap: widget.enableSearch,
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);
widget.onSelected?.call(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,
),
),
),
],
);
},
),
],
);
}
}

View File

@@ -1,287 +0,0 @@
import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/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),
// ],
// ),
// )
],
),
);
}
}

View File

@@ -1,113 +0,0 @@
import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
import 'package:mzansi_innovation_hub/mih_providers/mih_mine_sweeper_provider.dart';
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:provider/provider.dart';
class BuildMinesweeperLeaderboardList extends StatefulWidget {
const BuildMinesweeperLeaderboardList({super.key});
@override
State<BuildMinesweeperLeaderboardList> createState() =>
_BuildMinesweeperLeaderboardListState();
}
class _BuildMinesweeperLeaderboardListState
extends State<BuildMinesweeperLeaderboardList> {
Color getMedalColor(int index) {
switch (index) {
case (0):
return MihColors.getGoldColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
case (1):
return MihColors.getSilverColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
case (2):
return MihColors.getBronze(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
default:
return MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
}
}
@override
Widget build(BuildContext context) {
final double width = MediaQuery.sizeOf(context).width;
return Consumer2<MzansiProfileProvider, MihMineSweeperProvider>(
builder: (BuildContext context, MzansiProfileProvider profileProvider,
MihMineSweeperProvider mineSweeperProvider, Widget? child) {
return ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
);
},
itemCount: mineSweeperProvider.leaderboard!.length,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: width / 20),
child: Row(
children: [
Text(
"#${index + 1}",
style: TextStyle(
fontSize: 25,
color: getMedalColor(index),
),
),
const SizedBox(width: 10),
MihCircleAvatar(
key: UniqueKey(),
imageFile:
mineSweeperProvider.leaderboardUserPictures.isNotEmpty
? mineSweeperProvider.leaderboardUserPictures[index]
: null,
width: 80,
editable: false,
fileNameController: null,
userSelectedfile: null,
frameColor: getMedalColor(index),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
onChange: () {},
),
const SizedBox(width: 10),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${mineSweeperProvider.leaderboard![index].username}${profileProvider.user!.username == mineSweeperProvider.leaderboard![index].username ? " (You)" : ""}",
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: getMedalColor(index),
),
),
Text(
"Score: ${mineSweeperProvider.leaderboard![index].game_score}\nTime: ${mineSweeperProvider.leaderboard![index].game_time}",
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 18,
// fontWeight: FontWeight.bold,
color: getMedalColor(index),
),
),
],
)
],
),
);
},
);
},
);
}
}

View File

@@ -1,204 +0,0 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:ken_logger/ken_logger.dart';
import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
import 'package:mzansi_innovation_hub/mih_providers/mih_mine_sweeper_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_packages/mine_sweeper/builders/build_minesweeper_leaderboard_list.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_minesweeper_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
import 'package:provider/provider.dart';
class MihMineSweeperLeaderBoard extends StatefulWidget {
const MihMineSweeperLeaderBoard({super.key});
@override
State<MihMineSweeperLeaderBoard> createState() =>
_MihMineSweeperLeaderBoardState();
}
class _MihMineSweeperLeaderBoardState extends State<MihMineSweeperLeaderBoard> {
TextEditingController filterController = TextEditingController();
bool isLoading = true;
Future<void> initialiseLeaderboard() async {
MihMineSweeperProvider mineSweeperProvider =
context.read<MihMineSweeperProvider>();
filterController.text = mineSweeperProvider.difficulty;
KenLogger.success("getting data");
await MihMinesweeperServices().getTop20Leaderboard(mineSweeperProvider);
List<ImageProvider<Object>?> userPictures = [];
String userPicUrl = "";
for (final ranking in mineSweeperProvider.leaderboard!) {
userPicUrl = await MihFileApi.getMinioFileUrl(ranking.proPicUrl);
userPictures.add(NetworkImage(userPicUrl));
}
mineSweeperProvider.setLeaderboardUserPictures(
leaderboardUserPictures: userPictures);
setState(() {
isLoading = false;
});
}
void refreshLeaderBoard(
MihMineSweeperProvider mineSweeperProvider, String difficulty) {
setState(() {
isLoading = true;
});
mineSweeperProvider.setDifficulty(difficulty);
mineSweeperProvider.setLeaderboard(leaderboard: null);
mineSweeperProvider.setMyScoreboard(myScoreboard: null);
initialiseLeaderboard();
}
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
await initialiseLeaderboard();
});
}
@override
Widget build(BuildContext context) {
final double width = MediaQuery.sizeOf(context).width;
return Consumer<MihMineSweeperProvider>(
builder: (BuildContext context,
MihMineSweeperProvider mineSweeperProvider, Widget? child) {
return RefreshIndicator(
onRefresh: () async {
refreshLeaderBoard(mineSweeperProvider, filterController.text);
},
child: MihPackageToolBody(
borderOn: false,
bodyItem: getBody(width),
),
);
},
);
}
Widget getBody(double width) {
return Consumer<MihMineSweeperProvider>(
builder: (BuildContext context,
MihMineSweeperProvider mineSweeperProvider, Widget? child) {
if (isLoading) {
return Center(
child: Mihloadingcircle(),
);
} else {
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: width / 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
child: MihDropdownField(
controller: filterController,
hintText: "Leaderboards",
dropdownOptions: const [
"Very Easy",
"Easy",
"Intermediate",
"Hard",
],
requiredText: true,
editable: true,
enableSearch: false,
validator: (value) {
return MihValidationServices().isEmpty(value);
},
onSelected: (selection) {
refreshLeaderBoard(mineSweeperProvider, selection!);
},
),
),
],
),
),
const SizedBox(height: 10),
!isLoading && mineSweeperProvider.leaderboard!.isEmpty
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 50),
Icon(
MihIcons.mineSweeper,
size: 165,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
const SizedBox(height: 10),
Text(
"Be the first on the leaderboard.",
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(
FontAwesomeIcons.bomb,
size: 20,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
TextSpan(text: " and start a new game"),
],
),
),
),
],
),
)
: BuildMinesweeperLeaderboardList(),
],
),
);
}
},
);
}
}

View File

@@ -1,209 +0,0 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:ken_logger/ken_logger.dart';
import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
import 'package:mzansi_innovation_hub/mih_providers/mih_mine_sweeper_provider.dart';
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_packages/mine_sweeper/builders/build_my_scoreboard_list.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_minesweeper_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
import 'package:provider/provider.dart';
class MyScoreBoard extends StatefulWidget {
const MyScoreBoard({super.key});
@override
State<MyScoreBoard> createState() => _MihMineSweeperLeaderBoardState();
}
class _MihMineSweeperLeaderBoardState extends State<MyScoreBoard> {
TextEditingController filterController = TextEditingController();
Future<void> initialiseLeaderboard() async {
MzansiProfileProvider profileProvider =
context.read<MzansiProfileProvider>();
MihMineSweeperProvider mineSweeperProvider =
context.read<MihMineSweeperProvider>();
filterController.text = mineSweeperProvider.difficulty;
KenLogger.success("getting data");
await MihMinesweeperServices()
.getMyScoreboard(profileProvider, mineSweeperProvider);
KenLogger.success("${mineSweeperProvider.myScoreboard}");
}
void refreshLeaderBoard(
MihMineSweeperProvider mineSweeperProvider, String difficulty) {
mineSweeperProvider.setDifficulty(difficulty);
mineSweeperProvider.setLeaderboard(leaderboard: null);
mineSweeperProvider.setMyScoreboard(myScoreboard: null);
initialiseLeaderboard();
}
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
await initialiseLeaderboard();
});
}
@override
Widget build(BuildContext context) {
final double width = MediaQuery.sizeOf(context).width;
return Consumer<MihMineSweeperProvider>(
builder: (BuildContext context,
MihMineSweeperProvider mineSweeperProvider, Widget? child) {
return RefreshIndicator(
onRefresh: () async {
refreshLeaderBoard(mineSweeperProvider, filterController.text);
},
child: MihPackageToolBody(
borderOn: false,
bodyItem: getBody(width),
),
);
},
);
}
Widget getBody(double width) {
return Consumer2<MzansiProfileProvider, MihMineSweeperProvider>(
builder: (BuildContext context, MzansiProfileProvider profileProvider,
MihMineSweeperProvider mineSweeperProvider, Widget? child) {
if (mineSweeperProvider.myScoreboard == null) {
return Center(
child: Mihloadingcircle(),
);
} else {
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: [
Center(
child: MihCircleAvatar(
imageFile: profileProvider.userProfilePicture,
width: 150,
editable: false,
fileNameController: null,
userSelectedfile: null,
frameColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
onChange: (selectedImage) {},
key: ValueKey(profileProvider.userProfilePicUrl),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: width / 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
child: MihDropdownField(
controller: filterController,
hintText: "Scoreboards",
dropdownOptions: const [
"Very Easy",
"Easy",
"Intermediate",
"Hard",
],
requiredText: true,
editable: true,
enableSearch: false,
validator: (value) {
return MihValidationServices().isEmpty(value);
},
onSelected: (selection) {
refreshLeaderBoard(mineSweeperProvider, selection!);
},
),
),
],
),
),
const SizedBox(height: 10),
mineSweeperProvider.myScoreboard!.isEmpty
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 50),
Icon(
MihIcons.mineSweeper,
size: 165,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
const SizedBox(height: 10),
Text(
"You have played and ${mineSweeperProvider.difficulty} yet.",
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(
FontAwesomeIcons.bomb,
size: 20,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
TextSpan(text: " and start a new game"),
],
),
),
),
],
),
)
: BuildMyScoreBoardList(),
],
),
);
}
},
);
}
}

View File

@@ -1,556 +0,0 @@
import 'package:flutter/material.dart';
import 'package:ken_logger/ken_logger.dart';
import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
import 'package:mzansi_innovation_hub/mih_objects/business.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_dropdwn_field.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_search_bar.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart';
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_business_search_resultsList.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_user_search_results_list.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
import 'package:provider/provider.dart';
class MihSearchMzansi extends StatefulWidget {
const MihSearchMzansi({
super.key,
});
@override
State<MihSearchMzansi> createState() => _MihSearchMzansiState();
}
class _MihSearchMzansiState extends State<MihSearchMzansi> {
final TextEditingController mzansiSearchController = TextEditingController();
final TextEditingController businessTypeController = TextEditingController();
final FocusNode searchFocusNode = FocusNode();
// late bool userSearch;
// Future<List<AppUser>?> futureUserSearchResults = Future.value();
List<AppUser> userSearchResults = [];
List<Business> businessSearchResults = [];
late Future<List<String>> availableBusinessTypes;
bool filterOn = false;
bool loadingSearchResults = false;
Future<void> swapPressed(MzansiProfileProvider profileProvider,
MzansiDirectoryProvider directoryProvider) async {
directoryProvider.setPersonalSearch(!directoryProvider.personalSearch);
setState(() {
if (filterOn) {
filterOn = !filterOn;
}
});
if (businessTypeController.text.isNotEmpty) {
setState(() {
businessTypeController.clear();
});
}
await searchPressed(profileProvider, directoryProvider);
}
void clearAll(MzansiDirectoryProvider directoryProvider) {
directoryProvider.setSearchedBusinesses(searchedBusinesses: []);
directoryProvider.setSearchedUsers(searchedUsers: []);
directoryProvider.setSearchTerm(searchTerm: "");
setState(() {
mzansiSearchController.clear();
businessTypeController.clear();
});
}
Future<void> searchPressed(MzansiProfileProvider profileProvider,
MzansiDirectoryProvider directoryProvider) async {
setState(() {
loadingSearchResults = true;
});
directoryProvider.setSearchTerm(searchTerm: mzansiSearchController.text);
directoryProvider.setBusinessTypeFilter(
businessTypeFilter: businessTypeController.text);
if (directoryProvider.personalSearch &&
directoryProvider.searchTerm.isNotEmpty) {
final userResults = await MihUserServices()
.searchUsers(profileProvider, directoryProvider.searchTerm, context);
directoryProvider.setSearchedUsers(searchedUsers: userResults);
} else {
List<Business>? businessSearchResults = [];
if (directoryProvider.businessTypeFilter.isNotEmpty) {
businessSearchResults = await MihBusinessDetailsServices()
.searchBusinesses(directoryProvider.searchTerm,
directoryProvider.businessTypeFilter, context);
} else if (directoryProvider.searchTerm.isNotEmpty) {
businessSearchResults = await MihBusinessDetailsServices()
.searchBusinesses(directoryProvider.searchTerm,
directoryProvider.businessTypeFilter, context);
}
directoryProvider.setSearchedBusinesses(
searchedBusinesses: businessSearchResults);
}
setState(() {
loadingSearchResults = false;
});
}
@override
void dispose() {
super.dispose();
businessTypeController.dispose();
mzansiSearchController.dispose();
}
@override
void initState() {
super.initState();
MzansiDirectoryProvider directoryProvider =
context.read<MzansiDirectoryProvider>();
availableBusinessTypes =
MihBusinessDetailsServices().fetchAllBusinessTypes();
mzansiSearchController.text = "";
WidgetsBinding.instance.addPostFrameCallback((_) async {
directoryProvider.setSearchedUsers(searchedUsers: []);
});
}
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.sizeOf(context);
final double width = size.width;
return MihPackageToolBody(
borderOn: false,
bodyItem: getBody(width),
);
}
Widget getBody(double width) {
return Consumer2<MzansiProfileProvider, MzansiDirectoryProvider>(
builder: (BuildContext context, MzansiProfileProvider profileProvider,
MzansiDirectoryProvider directoryProvider, Widget? child) {
return MihSingleChildScroll(
child: Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: width / 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: MihSearchBar(
controller: mzansiSearchController,
hintText: "Search Mzansi",
prefixIcon: Icons.search,
prefixAltIcon: directoryProvider.personalSearch
? Icons.person
: Icons.business,
suffixTools: [
IconButton(
onPressed: () {
swapPressed(profileProvider, directoryProvider);
},
icon: Icon(
Icons.swap_horiz_rounded,
size: 35,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
],
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
hintColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onPrefixIconTap: () {
searchPressed(profileProvider, directoryProvider);
},
onClearIconTap: () {
clearAll(directoryProvider);
},
searchFocusNode: searchFocusNode,
),
),
Visibility(
visible: !directoryProvider.personalSearch,
child: const SizedBox(width: 10),
),
Visibility(
visible: !directoryProvider.personalSearch,
child: IconButton(
onPressed: () {
if (filterOn) {
clearAll(directoryProvider);
}
setState(() {
filterOn = !filterOn;
});
},
icon: Icon(
!filterOn
? Icons.filter_list_rounded
: Icons.filter_list_off_rounded,
size: 35,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
],
),
),
const SizedBox(height: 10),
FutureBuilder(
future: availableBusinessTypes,
builder: (context, asyncSnapshot) {
List<String> options = [];
if (asyncSnapshot.connectionState == ConnectionState.done) {
options.addAll(asyncSnapshot.data!);
}
return Visibility(
visible: filterOn,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: width / 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: MihDropdownField(
controller: businessTypeController,
hintText: "Business Type",
dropdownOptions: options,
requiredText: true,
editable: true,
enableSearch: true,
),
),
const SizedBox(width: 10),
MihButton(
onPressed: () {
if (businessTypeController.text.isNotEmpty) {
searchPressed(
profileProvider, directoryProvider);
} else {
MihAlertServices().errorBasicAlert(
"Business Type Not Selected",
"Please ensure you have selected a Business Type before seareching for Businesses of Mzansi",
context,
);
}
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
elevation: 10,
child: Text(
"Search",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
);
}),
const SizedBox(height: 10),
displaySearchResults(directoryProvider),
],
),
);
},
);
}
Widget displayBusinessSearchResults(
MzansiDirectoryProvider directoryProvider) {
KenLogger.success(
"Searched Businesses: ${directoryProvider.searchedBusinesses}");
if (directoryProvider.searchedBusinesses == null || loadingSearchResults) {
return Center(
child: const Mihloadingcircle(),
);
} else if (directoryProvider.searchedBusinesses!.isNotEmpty) {
// return Text("Pulled Data successfully");
directoryProvider.searchedBusinesses!
.sort((a, b) => a.Name.compareTo(b.Name));
return Column(
children: [
Text(
"Businesses of Mzansi",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
BuildBusinessSearchResultsList(
businessList: directoryProvider.searchedBusinesses!,
),
],
);
} else if (directoryProvider.searchedBusinesses!.isEmpty &&
directoryProvider.searchTerm.isNotEmpty) {
// return Text("Pulled Data successfully");
return Column(
children: [
const SizedBox(height: 50),
Icon(
MihIcons.iDontKnow,
size: 165,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
const SizedBox(height: 25),
Text(
"Let's try refining your search",
textAlign: TextAlign.center,
overflow: TextOverflow.visible,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
],
);
} else if (directoryProvider.searchedBusinesses!.isEmpty &&
directoryProvider.searchTerm.isEmpty) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 50),
Icon(
MihIcons.businessProfile,
size: 165,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
const SizedBox(height: 10),
Text(
"Search for businesses of Mzansi!",
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.swap_horiz_rounded,
size: 20,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
TextSpan(text: " to search for people of Mzansi"),
],
),
),
),
const SizedBox(height: 10),
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.filter_list_rounded,
size: 20,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
TextSpan(text: " to filter business types"),
],
),
),
),
],
),
);
} else {
return Center(
child: Text(
"Error pulling Patients Data\n/users/search/${directoryProvider.searchTerm}",
style: TextStyle(
fontSize: 25,
color: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
textAlign: TextAlign.center,
),
);
}
}
Widget displayPersonalSearchResults(
MzansiDirectoryProvider directoryProvider) {
if (directoryProvider.searchedUsers == null || loadingSearchResults) {
return Center(
child: const Mihloadingcircle(),
);
} else if (directoryProvider.searchedUsers!.isNotEmpty) {
// return Text("Pulled Data successfully");
directoryProvider.searchedUsers!
.sort((a, b) => a.username.compareTo(b.username));
return Column(
children: [
Text(
"People of Mzansi",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
BuildUserSearchResultsList(
userList: directoryProvider.searchedUsers!),
],
);
} else if (directoryProvider.searchedUsers!.isEmpty &&
directoryProvider.searchTerm.isEmpty) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 50),
Icon(
MihIcons.personalProfile,
size: 165,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
const SizedBox(height: 10),
Text(
"Search for people of Mzansi!",
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.swap_horiz_rounded,
size: 20,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
TextSpan(text: " to search for businesses of Mzansi"),
],
),
),
),
],
),
);
} else if (directoryProvider.searchedUsers!.isEmpty &&
directoryProvider.searchTerm.isNotEmpty) {
return Column(
children: [
const SizedBox(height: 50),
Icon(
MihIcons.iDontKnow,
size: 165,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
const SizedBox(height: 10),
Text(
"Let's try refining your search",
textAlign: TextAlign.center,
overflow: TextOverflow.visible,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
],
);
} else {
return Center(
child: Text(
"Error pulling Patients Data\n/users/search/${directoryProvider.searchTerm}",
style: TextStyle(
fontSize: 25,
color: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
textAlign: TextAlign.center,
),
);
}
}
Widget displaySearchResults(MzansiDirectoryProvider directoryProvider) {
if (directoryProvider.personalSearch) {
return displayPersonalSearchResults(directoryProvider);
} else {
return displayBusinessSearchResults(directoryProvider);
}
}
}

View File

@@ -1,620 +0,0 @@
import 'package:country_code_picker/country_code_picker.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.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_package_components/mih_button.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
import 'package:provider/provider.dart';
class MihUpdateBusinessDetailsWindow extends StatefulWidget {
final double width;
const MihUpdateBusinessDetailsWindow({
super.key,
required this.width,
});
@override
State<MihUpdateBusinessDetailsWindow> createState() =>
_MihUpdateBusinessDetailsWindowState();
}
class _MihUpdateBusinessDetailsWindowState
extends State<MihUpdateBusinessDetailsWindow> {
final _formKey = GlobalKey<FormState>();
PlatformFile? newSelectedLogoPic;
final fileNameController = TextEditingController();
final regController = TextEditingController();
final nameController = TextEditingController();
final typeController = TextEditingController();
final practiceNoController = TextEditingController();
final vatNoController = TextEditingController();
final countryCodeController = TextEditingController();
final contactController = TextEditingController();
final emailController = TextEditingController();
final locationController = TextEditingController();
final websiteController = TextEditingController();
final ratingController = TextEditingController();
final missionVisionController = TextEditingController();
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
late String env;
void setContactNumberControllers(
MzansiProfileProvider mzansiProfileProvider) {
if (mzansiProfileProvider.business!.contact_no[0] == "+") {
List<String> contactDetails =
mzansiProfileProvider.business!.contact_no.split("-");
setState(() {
countryCodeController.text = contactDetails[0];
contactController.text = contactDetails[1];
});
} else {
setState(() {
countryCodeController.text = "+27";
contactController.text = mzansiProfileProvider.business!.contact_no;
});
}
}
void setControllers() {
MzansiProfileProvider mzansiProfileProvider =
context.read<MzansiProfileProvider>();
setState(() {
fileNameController.text =
mzansiProfileProvider.business!.logo_path.split("/").last;
regController.text = mzansiProfileProvider.business!.registration_no;
nameController.text = mzansiProfileProvider.business!.Name;
typeController.text = mzansiProfileProvider.business!.type;
practiceNoController.text = mzansiProfileProvider.business!.practice_no;
vatNoController.text = mzansiProfileProvider.business!.vat_no;
emailController.text = mzansiProfileProvider.business!.bus_email;
locationController.text = mzansiProfileProvider.business!.gps_location;
websiteController.text = mzansiProfileProvider.business!.website;
ratingController.text = mzansiProfileProvider.business!.rating;
missionVisionController.text =
mzansiProfileProvider.business!.mission_vision;
});
setContactNumberControllers(mzansiProfileProvider);
if (AppEnviroment.getEnv() == "Prod") {
env = "Prod";
} else {
env = "Dev";
}
}
Color getMissionVisionLimitColor(int limit) {
if (_counter.value <= limit) {
return MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
} else {
return MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
}
}
void _updateMissionVisionCounter() {
// New function name
// No need for setState since you are using a ValueNotifier for _counter
_counter.value = missionVisionController.text.characters.length;
}
String getNumberWithCountryCode() {
String numberWithoutBeginingZero = "";
if (contactController.text[0] == "0") {
numberWithoutBeginingZero = contactController.text
.replaceAll(" ", "")
.substring(1, contactController.text.length);
} else {
numberWithoutBeginingZero = contactController.text.replaceAll("-", " ");
}
return "${countryCodeController.text}-$numberWithoutBeginingZero";
}
bool isFormFilled() {
if (typeController.text.isEmpty) {
return false;
} else {
return true;
}
}
void successPopUp(String message, bool stayOnPersonalSide) {
MihAlertServices().successBasicAlert(
"Success!",
message,
context,
);
}
Future<bool> uploadFile(MzansiProfileProvider mzansiProfileProvider) async {
if (newSelectedLogoPic != null) {
int uploadStatusCode = 0;
uploadStatusCode = await MihFileApi.uploadFile(
mzansiProfileProvider.business!.business_id,
env,
"business_files",
newSelectedLogoPic!,
context,
);
if (uploadStatusCode == 200) {
int deleteStatusCode = 0;
deleteStatusCode = await MihFileApi.deleteFile(
mzansiProfileProvider.business!.logo_path.split("/").first,
env,
"business_files",
mzansiProfileProvider.business!.logo_path.split("/").last,
context,
);
if (deleteStatusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return true; // No file selected, so no upload needed
}
}
Future<void> submitForm(MzansiProfileProvider mzansiProfileProvider) async {
KenLogger.success("Start Submit Form");
if (isFormFilled()) {
KenLogger.success("Form Filled");
KenLogger.success("Start File Upload");
bool successfullyUploadedFile = await uploadFile(mzansiProfileProvider);
KenLogger.success(
"File Upload Complete: outcome $successfullyUploadedFile");
if (!mounted) return;
KenLogger.success("is mounted");
if (successfullyUploadedFile) {
KenLogger.success("Start Details Update");
int statusCode = 0;
statusCode = await MihBusinessDetailsServices().updateBusinessDetailsV2(
mzansiProfileProvider.business!.business_id,
nameController.text,
typeController.text,
regController.text,
practiceNoController.text,
vatNoController.text,
emailController.text,
getNumberWithCountryCode(),
// contactController.text,
locationController.text,
fileNameController.text,
websiteController.text,
ratingController.text.isEmpty ? "0" : ratingController.text,
missionVisionController.text,
mzansiProfileProvider,
context,
);
KenLogger.success("Details Update Complete: status code $statusCode");
if (!mounted) return;
KenLogger.success("is mounted");
if (statusCode == 200) {
KenLogger.success("Start Success Message");
//You left of here
String message = "Your information has been updated successfully!";
context.pop();
successPopUp(message, false);
// File uploaded successfully
} else {
context.pop();
// File upload failed
MihAlertServices().errorBasicAlert(
"Error Updating Business Details",
"An error occurred while updating the business details. Please try again.",
context,
);
}
} else {
context.pop();
if (!mounted) return;
MihAlertServices().internetConnectionAlert(context);
}
} else {
MihAlertServices().inputErrorAlert(context);
}
}
@override
void initState() {
super.initState();
setControllers();
missionVisionController.addListener(_updateMissionVisionCounter);
}
@override
Widget build(BuildContext context) {
return Consumer<MzansiProfileProvider>(
builder: (BuildContext context,
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
return MihPackageWindow(
fullscreen: false,
windowTitle: 'Edit Profile',
onWindowTapClose: () {
context.pop();
},
windowBody: MihSingleChildScroll(
child: Padding(
padding:
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
? EdgeInsets.symmetric(horizontal: widget.width * 0.05)
: EdgeInsets.symmetric(horizontal: widget.width * 0),
child: Column(
children: [
MihForm(
formKey: _formKey,
formFields: [
Center(
child: MihCircleAvatar(
imageFile: newSelectedLogoPic != null
? MemoryImage(newSelectedLogoPic!.bytes!)
: mzansiProfileProvider.businessProfilePicture,
width: 150,
editable: true,
fileNameController: fileNameController,
userSelectedfile: newSelectedLogoPic,
frameColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onChange: (selectedfile) {
setState(() {
newSelectedLogoPic = selectedfile;
});
},
),
),
Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected File Name",
),
),
const SizedBox(height: 20),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: nameController,
multiLineInput: false,
requiredText: true,
hintText: "Business Name",
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: typeController,
multiLineInput: false,
requiredText: true,
hintText: "Business Type",
validator: (value) {
return MihValidationServices()
.validateNoSpecialChars(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: emailController,
multiLineInput: false,
requiredText: true,
hintText: "Business Email",
validator: (value) {
return MihValidationServices().validateEmail(value);
},
),
const SizedBox(height: 10),
Container(
width: 300,
alignment: Alignment.topLeft,
child: const Text(
"Contact Number:",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
CountryCodePicker(
padding: EdgeInsetsGeometry.all(0),
onChanged: (selectedCode) {
setState(() {
countryCodeController.text =
selectedCode.toString();
});
debugPrint(
"Selected Country Code: ${countryCodeController.text}");
},
initialSelection: countryCodeController.text,
showDropDownButton: false,
pickerStyle: PickerStyle.bottomSheet,
dialogBackgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
barrierColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
Expanded(
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: contactController,
numberMode: true,
multiLineInput: false,
requiredText: true,
hintText: null,
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
),
],
),
const SizedBox(height: 10),
MihTextFormField(
height: 250,
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: missionVisionController,
multiLineInput: true,
requiredText: true,
hintText: "Business Mission & Vision",
validator: (value) {
return MihValidationServices().validateLength(
missionVisionController.text, 256);
},
),
SizedBox(
height: 15,
child: ValueListenableBuilder(
valueListenable: _counter,
builder:
(BuildContext context, int value, Widget? child) {
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"$value",
style: TextStyle(
color: getMissionVisionLimitColor(256),
fontWeight: FontWeight.bold,
),
),
const SizedBox(width: 5),
Text(
"/256",
style: TextStyle(
color: getMissionVisionLimitColor(256),
fontWeight: FontWeight.bold,
),
),
],
);
},
),
),
const SizedBox(height: 10.0),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: websiteController,
multiLineInput: false,
requiredText: false,
hintText: "Business Website",
validator: (value) {
return MihValidationServices()
.validateWebsite(value, false);
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: regController,
multiLineInput: false,
requiredText: false,
hintText: "Registration No.",
validator: (value) {
// return MihValidationServices().isEmpty(value);
return null;
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: practiceNoController,
multiLineInput: false,
requiredText: false,
hintText: "Practice Number",
validator: (validateValue) {
return null;
},
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: vatNoController,
multiLineInput: false,
requiredText: false,
hintText: "VAT Number",
validator: (value) {
// return MihValidationServices().isEmpty(value);
return null;
},
),
const SizedBox(height: 10),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: locationController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "GPS Location",
),
),
const SizedBox(width: 10.0),
MihButton(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return const Mihloadingcircle(
message: "Getting your location",
);
},
);
MIHLocationAPI()
.getGPSPosition(context)
.then((position) {
if (position != null) {
setState(() {
locationController.text =
"${position.latitude}, ${position.longitude}";
});
}
//Dismiss loading indicator
context.pop();
});
},
buttonColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
width: 100,
child: Text(
"Set",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
],
),
const SizedBox(height: 25),
Center(
child: MihButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
submitForm(mzansiProfileProvider);
} else {
MihAlertServices().inputErrorAlert(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,
),
),
),
),
const SizedBox(height: 20),
],
),
],
),
),
),
);
},
);
}
}

View File

@@ -1,372 +0,0 @@
import 'package:file_picker/file_picker.dart';
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_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_image_display.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_my_business_user_services.dart';
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
import 'package:provider/provider.dart';
class MihUpdateMyBusinessUserDetails extends StatefulWidget {
const MihUpdateMyBusinessUserDetails({super.key});
@override
State<MihUpdateMyBusinessUserDetails> createState() =>
_MihUpdateMyBusinessUserDetailsState();
}
class _MihUpdateMyBusinessUserDetailsState
extends State<MihUpdateMyBusinessUserDetails> {
final fileNameController = TextEditingController();
final titleTextController = TextEditingController();
final fnameController = TextEditingController();
final lnameController = TextEditingController();
final accessController = TextEditingController();
final signtureController = TextEditingController();
final _formKey = GlobalKey<FormState>();
PlatformFile? userPicFile;
PlatformFile? newSelectedSignaturePic;
late String env;
bool isFormFilled() {
if (titleTextController.text.isEmpty) {
return false;
} else {
return true;
}
}
Future<bool> uploadFile(MzansiProfileProvider mzansiProfileProvider) async {
if (newSelectedSignaturePic != null) {
int uploadStatusCode = 0;
uploadStatusCode = await MihFileApi.uploadFile(
mzansiProfileProvider.user!.app_id,
env,
"business_files",
newSelectedSignaturePic!,
context,
);
if (uploadStatusCode == 200) {
signtureController.text = newSelectedSignaturePic!.name;
int deleteStatusCode = 0;
deleteStatusCode = await MihFileApi.deleteFile(
mzansiProfileProvider.user!.app_id,
env,
"business_files",
mzansiProfileProvider.businessUser!.sig_path.split("/").last,
context,
);
if (deleteStatusCode == 200) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return true; // No file selected, so no upload needed
}
}
Future<void> submitForm(MzansiProfileProvider mzansiProfileProvider) async {
if (isFormFilled()) {
bool successfullyUploadedFile = await uploadFile(mzansiProfileProvider);
if (!mounted) return;
if (successfullyUploadedFile) {
int statusCode = await MihMyBusinessUserServices().updateBusinessUser(
mzansiProfileProvider.user!.app_id,
mzansiProfileProvider.businessUser!.business_id,
titleTextController.text,
accessController.text,
signtureController.text,
mzansiProfileProvider,
context,
);
if (!mounted) return;
if (statusCode == 200) {
String message = "Business details updated successfully";
context.pop();
successPopUp(message, false);
} else {
MihAlertServices().errorBasicAlert(
"Error Updating Business User Details",
"An error occurred while updating the business User details. Please check internet connection and try again.",
context,
);
}
} else {
MihAlertServices().internetConnectionAlert(context);
}
} else {
MihAlertServices().inputErrorAlert(context);
}
}
void successPopUp(String message, bool stayOnPersonalSide) {
MihAlertServices().successBasicAlert(
"Success!",
message,
context,
);
}
Widget getWindowBody(double width) {
return Consumer<MzansiProfileProvider>(
builder: (BuildContext context,
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
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: [
Center(
child: MihCircleAvatar(
imageFile: mzansiProfileProvider.userProfilePicture,
width: 150,
editable: false,
fileNameController: fileNameController,
userSelectedfile: userPicFile,
frameColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onChange: (_) {},
),
),
Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected File Name",
),
),
const SizedBox(height: 10),
MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: titleTextController,
multiLineInput: false,
requiredText: true,
readOnly: false,
hintText: "Title",
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: fnameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "First Name",
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: lnameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Surname",
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: accessController,
multiLineInput: false,
requiredText: true,
hintText: "Access Level",
readOnly: true,
validator: (value) {
return MihValidationServices().isEmpty(value);
},
),
const SizedBox(height: 10),
Container(
width: 300,
alignment: Alignment.topLeft,
child: const Text(
"Signature:",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Center(
child: MihImageDisplay(
imageFile: newSelectedSignaturePic != null
? MemoryImage(newSelectedSignaturePic!.bytes!)
: mzansiProfileProvider.businessUserSignature,
width: 300,
height: 200,
editable: true,
fileNameController: signtureController,
userSelectedfile: newSelectedSignaturePic,
onChange: (selectedFile) {
setState(() {
newSelectedSignaturePic = selectedFile;
});
},
),
),
const SizedBox(height: 10),
Visibility(
visible: false,
child: MihTextFormField(
fillColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
inputColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
controller: fileNameController,
multiLineInput: false,
requiredText: true,
readOnly: true,
hintText: "Selected Signature File",
),
),
const SizedBox(height: 15),
Center(
child: MihButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
submitForm(mzansiProfileProvider);
} else {
MihAlertServices().inputErrorAlert(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,
),
),
),
),
const SizedBox(height: 20),
],
),
],
),
),
);
},
);
}
void setControllers() {
MzansiProfileProvider mzansiProfileProvider =
context.read<MzansiProfileProvider>();
fileNameController.text =
mzansiProfileProvider.user!.pro_pic_path.split("/").last;
signtureController.text =
mzansiProfileProvider.businessUser!.sig_path.split("/").last;
titleTextController.text = mzansiProfileProvider.businessUser!.title;
fnameController.text = mzansiProfileProvider.user!.fname;
lnameController.text = mzansiProfileProvider.user!.lname;
accessController.text = mzansiProfileProvider.businessUser!.access;
if (AppEnviroment.getEnv() == "Prod") {
env = "Prod";
} else {
env = "Dev";
}
}
@override
void dispose() {
super.dispose();
fileNameController.dispose();
titleTextController.dispose();
fnameController.dispose();
lnameController.dispose();
accessController.dispose();
signtureController.dispose();
userPicFile = null;
newSelectedSignaturePic = null;
}
@override
void initState() {
super.initState();
setControllers();
}
@override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
return MihPackageWindow(
fullscreen: false,
windowTitle: "Edit Profile",
onWindowTapClose: () {
context.pop();
},
windowBody: getWindowBody(screenWidth),
);
}
}

View File

@@ -1,182 +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_package_components/mih_button.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/components/mih_edit_personal_profile_window.dart';
import 'package:provider/provider.dart';
class MihPersonalProfile extends StatefulWidget {
const MihPersonalProfile({super.key});
@override
State<MihPersonalProfile> createState() => _MihPersonalProfileState();
}
class _MihPersonalProfileState extends State<MihPersonalProfile> {
TextEditingController proPicController = TextEditingController();
PlatformFile? newSelectedProPic;
void editProfileWindow(double width) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Consumer<MzansiProfileProvider>(
builder: (BuildContext context,
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
return MihEditPersonalProfileWindow();
},
),
);
}
@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 Consumer<MzansiProfileProvider>(
builder: (BuildContext context,
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
if (mzansiProfileProvider.user == null) {
//Change to new user flow
return Center(
child: Mihloadingcircle(),
);
} else {
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(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Center(
child: MihCircleAvatar(
imageFile: mzansiProfileProvider.userProfilePicture,
width: 150,
editable: false,
fileNameController: proPicController,
userSelectedfile: newSelectedProPic,
frameColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
onChange: (selectedImage) {
setState(() {
newSelectedProPic = selectedImage;
});
},
key: ValueKey(mzansiProfileProvider.userProfilePicUrl),
),
),
FittedBox(
child: Text(
mzansiProfileProvider.user!.username.isNotEmpty
? mzansiProfileProvider.user!.username
: "username",
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
FittedBox(
child: Text(
mzansiProfileProvider.user!.fname.isNotEmpty
? "${mzansiProfileProvider.user!.fname} ${mzansiProfileProvider.user!.lname}"
: "Name Surname",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
FittedBox(
child: Text(
mzansiProfileProvider.user!.type == "business"
? "Business".toUpperCase()
: "Personal".toUpperCase(),
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
const SizedBox(height: 10.0),
Center(
child: SizedBox(
width: 700,
child: Text(
mzansiProfileProvider.user!.purpose.isNotEmpty
? mzansiProfileProvider.user!.purpose
: "No Personal Mission added yet",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
),
),
),
),
const SizedBox(height: 30.0),
Center(
child: MihButton(
onPressed: () {
// Connect with the user
editProfileWindow(width);
},
buttonColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
width: 300,
child: Text(
mzansiProfileProvider.user!.username.isEmpty
? "Set Up Profile"
: "Edit Profile",
style: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode ==
"Dark"),
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
);
}
},
);
}
}

View File

@@ -1,62 +0,0 @@
import 'package:flutter/foundation.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
class MihBannerAdProvider extends ChangeNotifier {
BannerAd? bannerAd;
final adUnitId = AppEnviroment.bannerAdUnitId;
bool isBannerAdLoaded = false;
String errorMessage = '';
MihBannerAdProvider({
this.bannerAd,
this.isBannerAdLoaded = false,
this.errorMessage = '',
});
void reset() {
bannerAd = null;
isBannerAdLoaded = false;
errorMessage = "";
notifyListeners();
}
@override
void dispose() {
bannerAd?.dispose();
super.dispose();
}
void loadBannerAd() {
if (bannerAd != null) {
bannerAd!.dispose();
bannerAd = null;
isBannerAdLoaded = false;
}
bannerAd = BannerAd(
adUnitId: adUnitId,
request: const AdRequest(),
size: AdSize.banner,
listener: BannerAdListener(
onAdLoaded: (ad) {
debugPrint('$ad loaded.');
isBannerAdLoaded = true;
notifyListeners();
},
onAdFailedToLoad: (ad, err) {
debugPrint('BannerAd failed to load: $err');
errorMessage =
'Failed to load ad- Message: ${err.message} Code :${err.code}';
ad.dispose(); // Dispose the ad to free resources
isBannerAdLoaded = false; // ⬅️ Explicitly set to false
bannerAd = null; // ⬅️ Explicitly set to null
notifyListeners();
},
onAdOpened: (Ad ad) => debugPrint('$ad opened.'),
onAdClosed: (Ad ad) => debugPrint('$ad closed.'),
onAdImpression: (Ad ad) => debugPrint('$ad impression.'),
),
);
bannerAd!.load();
}
}

View File

@@ -1,328 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_ai_toolkit/flutter_ai_toolkit.dart';
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
import 'package:mzansi_innovation_hub/main.dart';
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
import 'package:mzansi_innovation_hub/mih_providers/ollama_provider.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
class MzansiAiProvider extends ChangeNotifier {
bool ttsOn;
int toolIndex;
String? startUpQuestion;
late OllamaProvider ollamaProvider;
MzansiAiProvider({
this.toolIndex = 0,
this.ttsOn = false,
}) {
ollamaProvider = OllamaProvider(
baseUrl: "${AppEnviroment.baseAiUrl}/api",
model: AppEnviroment.getEnv() == "Prod" ? 'gemma3n:e4b' : "gemma3:1b",
systemPrompt: "You are Mzansi AI, a helpful and friendly AI assistant running on the 'MIH App'.\n" +
"The MIH App was created by 'Mzansi Innovation Hub', a South African-based startup company." +
"Your primary purpose is to assist users by answering general questions and helping with creative writing tasks or any other task a user might have for you.\n" +
"Maintain a casual and friendly tone, but always remain professional.\n" +
"Strive for a balance between being empathetic and delivering factual information accurately.\n" +
"You may use lighthearted or playful language if the context is appropriate and enhances the user experience.\n" +
"You operate within the knowledge domain of the 'MIH App'.\n" +
"Here is a description of the MIH App and its features:\n" +
"MIH App Description: MIH is the first super app of Mzansi, designed to streamline both personal and business life. It's an all-in-one platform for managing professional profiles, teams, appointments, and quick calculations. \n" +
"Key Features:\n" +
"- Mzansi Profile: Central hub for managing personal and business information, including business team details." +
"- Mzansi Wallet: Digitally store loyalty cards.\n" +
"- Patient Manager (For Medical Practices): Seamless patient appointment scheduling and data management.\n" +
"- Mzansi AI: Your friendly AI assistant for quick answers and support (that's you!).\n" +
"- Mzansi Directory: A place to search and find out more about the people and businesses across Mzansi.\n" +
"- Calendar: Integrated calendar for managing personal and business appointments.\n" +
"- Calculator: Simple calculator with tip and forex calculation functionality.\n" +
"- MIH Minesweeper: The first game from MIH! It's the classic brain-teaser ready to entertain you no matter where you are.\n" +
"- MIH Access: Manage and view profile access security.\n" +
"**Core Rules and Guidelines:**\n" +
"- **Accuracy First:** Always prioritize providing correct information.\n" +
"- **Uncertainty Handling:** If you are unsure about an answer, politely respond with: 'Please bear with us as we are still learning and do not have all the answers.'\n" +
"- **Response Length:** Aim to keep responses under 250 words. If a more comprehensive answer is required, exceed this limit but offer to elaborate further (e.g., 'Would you like me to elaborate on this topic?').\n" +
"- **Language & Safety:** Never use offensive language or generate harmful content. If a user presses for information that is inappropriate or out of bounds, clearly state why you cannot provide it (e.g., 'I cannot assist with that request as it goes against my safety guidelines.').\n" +
"- **Out-of-Scope Questions:** - If a question is unclear, ask the user to rephrase or clarify it. - If a question is entirely out of your scope and you cannot provide a useful answer, admit you don't know. - If a user is unhappy with your response or needs further assistance beyond your capabilities, suggest they visit the 'Mzansi Innovation Hub Social Media Pages' for more direct support. Do not provide specific links, just refer to the pages generally.\n" +
"- **Target Audience:** Adapt your explanations to beginners and intermediate users, but be prepared for more complex questions from expert users. Ensure your language is clear and easy to understand.\n",
)..addListener(() {
notifyListeners(); // Forward OllamaProvider notifications
});
}
void reset() {
toolIndex = 0;
startUpQuestion = null;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();
}
void setTTSstate(bool ttsOn) {
this.ttsOn = ttsOn;
notifyListeners();
}
void setStartUpQuestion(String? question) {
startUpQuestion = question;
notifyListeners();
}
void clearStartUpQuestion() {
startUpQuestion = null;
}
MarkdownStyleSheet getLlmChatMarkdownStyle(BuildContext context) {
TextStyle body = TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
fontSize: 16,
fontWeight: FontWeight.w400,
);
TextStyle heading1 = TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
fontSize: 24,
fontWeight: FontWeight.w400,
);
TextStyle heading2 = TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
fontSize: 20,
fontWeight: FontWeight.w400,
);
TextStyle code = TextStyle(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
fontSize: 16,
fontWeight: FontWeight.w400,
);
BoxDecoration codeBlock = BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
color: MihColors.getHighlightColor(
MzansiInnovationHub.of(context)!.theme.mode != "Dark"),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(76),
blurRadius: 8,
offset: Offset(2, 2),
),
],
);
return MarkdownStyleSheet(
a: body,
blockquote: body,
checkbox: body,
del: body,
em: body.copyWith(fontStyle: FontStyle.italic),
h1: heading1,
h2: heading2,
h3: body.copyWith(fontWeight: FontWeight.bold),
h4: body,
h5: body,
h6: body,
listBullet: body,
img: body,
strong: body.copyWith(fontWeight: FontWeight.bold),
p: body,
tableBody: body,
tableHead: body,
code: code,
codeblockDecoration: codeBlock,
);
}
LlmChatViewStyle? getChatStyle(BuildContext context) {
return LlmChatViewStyle(
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
progressIndicatorColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
menuColor: Colors.black,
// MihColors.getGreenColor(
// MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
disabledButtonStyle: ActionButtonStyle(
icon: MihIcons.mzansiAi,
iconColor: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
iconDecoration: BoxDecoration(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
),
),
recordButtonStyle: ActionButtonStyle(
iconColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
iconDecoration: BoxDecoration(
color: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
),
textStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
submitButtonStyle: ActionButtonStyle(
icon: Icons.send,
iconColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
iconDecoration: BoxDecoration(
color: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
),
textStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
stopButtonStyle: ActionButtonStyle(
iconColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
iconDecoration: BoxDecoration(
color: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
),
textStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
actionButtonBarDecoration: BoxDecoration(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
),
// Mzansi AI Chat Style
llmMessageStyle: LlmMessageStyle(
icon: MihIcons.mzansiAi,
iconColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
iconDecoration: BoxDecoration(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
bottomLeft: Radius.circular(25),
bottomRight: Radius.circular(25),
),
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(76),
blurRadius: 8,
offset: Offset(2, 2),
),
],
),
markdownStyle: getLlmChatMarkdownStyle(context),
),
// User Chat Style
userMessageStyle: UserMessageStyle(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25),
bottomLeft: Radius.circular(25),
bottomRight: Radius.circular(25),
),
color: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(76),
blurRadius: 8,
offset: Offset(2, 2),
),
],
),
textStyle: TextStyle(
fontSize: 16,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
// User Input Style
chatInputStyle: ChatInputStyle(
backgroundColor: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
decoration: BoxDecoration(
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(76),
blurRadius: 8,
offset: Offset(2, 2),
),
],
),
hintStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
hintText: "Ask Mzansi AI...",
),
// Suggestions Style
suggestionStyle: SuggestionStyle(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25),
bottomLeft: Radius.circular(25),
bottomRight: Radius.circular(25),
),
color: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(76),
blurRadius: 8,
offset: Offset(2, 2),
),
],
),
textStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
copyButtonStyle: ActionButtonStyle(
iconColor: MihColors.getSecondaryInvertedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
editButtonStyle: ActionButtonStyle(
iconColor: MihColors.getSecondaryInvertedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
cancelButtonStyle: ActionButtonStyle(
iconDecoration: BoxDecoration(
color: MihColors.getRedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
borderRadius: BorderRadius.circular(25),
),
iconColor: MihColors.getSecondaryInvertedColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
textStyle: TextStyle(
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
),
),
);
}
}

View File

@@ -1,30 +0,0 @@
#!/usr/bin/env python
# Inspired by https://gist.github.com/jtangelder/e445e9a7f5e31c220be6
# Python3 http.server for Single Page Application
import urllib.parse
import http.server
import socketserver
import re
from pathlib import Path
port = 83
HOST = ('', port)
pattern = re.compile('.png|.jpg|.jpeg|.js|.css|.ico|.gif|.svg|.ico', re.IGNORECASE)
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
url_parts = urllib.parse.urlparse(self.path)
request_file_path = Path(url_parts.path.strip("/"))
ext = request_file_path.suffix
if not request_file_path.is_file() and not pattern.match(ext):
self.path = 'index.html'
return http.server.SimpleHTTPRequestHandler.do_GET(self)
httpd = socketserver.TCPServer(HOST, Handler)
print(f"Starting Web App Server on pot: {port}")
httpd.serve_forever()

View File

@@ -1,18 +0,0 @@
#!/bin/bash
# Define the port
PORT=83
# Check if the port is in use and release it if necessary.
# echo "Checking if port $PORT is in use..."
# if [ "$(lsof -t -i :$PORT)" ]; then
# echo "Port $PORT is in use. Stopping the process on that port..."
# fuser -k -n tcp $PORT
# fi
# Switch to the web construction directory
cd /app/build/web/
# Start the web server on the specified port
#python3 -m http.server 83
python3 -u ../../server/MIH_web_server.py

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

674
LICENSE Normal file
View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
The MIH Project is the first open-source super app of Mzansi.
Copyright (C) 2026 MZANSI INNOVATION HUB (PTY) LTD
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) 2026 MZANSI INNOVATION HUB (PTY) LTD
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -1,4 +1,5 @@
<h1>How to create your flavour of the MIH Server</h1>
<h1>The MIH Project</h1>
learn how to create your own flavour of the MIH Server.
<h2>Prerequisite:-</h2>
<ol>
<li>Ubuntu Server OS installed (24.04 tested)</li>
@@ -9,7 +10,7 @@
<h2>Get Started:-</h2>
<ol>
<li>Clone Git Repo.</li>
<li>Navigate to Mzansi-Innovation-Hub directory. <pre><code>cd Mzansi-Innovation-Hub</code></pre></li>
<li>Navigate to mih-project directory. <pre><code>cd mih-project</code></pre></li>
<li>Create .env file in the same location as docker-compose.yml<pre><code>
SQL_ROOT_PW=*PASSWORD*
SQL_USER=*USER*
@@ -26,18 +27,25 @@ CERTBOT_APP_DOMAIN=*APP_DOMAIN*
CERTBOT_API_DOMAIN=*API_DOMAIN*
CERTBOT_STORAGE_DOMAIN=*STORAGE_DOMAIN*
CERTBOT_MONITOR_DOMAIN=*MONITOR_DOMAIN*
CERTBOT_AI_DOMAIN=*AI_DOMAIN*</code></pre></li>
CERTBOT_AI_DOMAIN=*AI_DOMAIN*
GITEA_SQL_ROOT_PW=*GITEA_SQL_ROOT_PW*
GITEA_SQL_USER=*GITEA_SQL_USER*
GITEA_SQL_PW=*GITEA_SQL_PW*
GITEA_SQL_DB=*GITEA_SQL_DB*
WP_SQL_DB=*WP_SQL_DB*
WP_SQL_ROOT_PW=*WP_SQL_ROOT_PW*
WP_SQL_USER=*WP_SQL_USER*
WP_SQL_USER_PW=*WP_SQL_USER_PW*
</code></pre></li>
<li>Configure MIH-AI.</li>
<ol>
<li>If your server hardware has an Nvidia GPU, follow the instructions below "How to enable MIH-AI GPU usage"</li>
<li>If your server hardware does not use an Nvidia GPU, continue with the next step.</li>
</ol>
<li>Start MIH Server.</li>
<ol>
<li>Non-Prod: <pre><code>sudo docker compose up -d --build</code></pre></li>
<li>Prod: <pre><code>sudo docker compose --profile prod up -d --build</code></pre></li>
<li>Prod with Letsincrypt certificate Generation: <pre><code>sudo docker compose --profile prod --profile withCert up -d --build</code></pre></li>
</ol>
<pre><code>sudo docker compose up -d --build</code></pre>
<li>Check the status of the new MIH server using Portainer. <code>https://localhost:9443/</code> (Change Local Host to IP if necessary).</li>
<ol>
<li>If all containers are running without errors, proceed to step 5<br>(<b>NOTE:</b> certbot container will stop after running successfully).</li>
@@ -55,11 +63,7 @@ CERTBOT_AI_DOMAIN=*AI_DOMAIN*</code></pre></li>
</ol>
<h2>How to Stop MIH Server:-</h2>
<ol>
<li>Non-Prod: disables Nginx & CertBot container creation.<pre><code>sudo docker compose down</code></pre></li>
<li>Prod: <pre><code>sudo docker compose --profile prod down</code></pre></li>
<li>Prod with Letsincrypt certificate Generation: <pre><code>sudo docker compose --profile prod --profile withCert down</code></pre></li>
</ol>
<pre><code>sudo docker compose down</code></pre>
<h2>How to enable MIH-AI GPU:-</h2>
<ol>

3
backend/.gitignore vendored
View File

@@ -1,3 +0,0 @@
.env
__pycache__/
temp*.pdf

View File

@@ -1,28 +0,0 @@
# from supertokens_python import init, InputAppInfo, SupertokensConfig
# from supertokens_python.recipe import emailpassword, session, dashboard
# init(
# app_info=InputAppInfo(
# app_name="MIH_API_HUB",
# api_domain="http://localhost:8080/",
# website_domain="http://mzansi-innovation-hub.co.za",
# api_base_path="/auth",
# website_base_path="/auth"
# ),
# supertokens_config=SupertokensConfig(
# # https://try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
# connection_uri="supertokens:3567/",
# api_key="leatucczyixqwkqqdrhayiwzeofkltds"
# ),
# framework='fastapi',
# recipe_list=[
# # SuperTokens.init(),
# session.init(), # initializes session features
# emailpassword.init(),
# dashboard.init(admins=[
# "yasienmeth@gmail.com",
# ],
# )
# ],
# mode='wsgi' # use wsgi instead of asgi if you are running using gunicorn
# )

View File

@@ -1,62 +1,86 @@
#============== MIH Network ====================================================================
networks:
mih-network:
driver: bridge
#============== MIH Containers ====================================================================
services:
#============== API Hub ====================================================================
api:
build:
context: ./backend
target: builder
container_name: MIH-API-Hub
#command: sh -c "sleep 10s; uvicorn backend.main:app --reload --port=8080 --host=0.0.0.0"
#============Dev=================
# command: sh -c "sleep 10s; fastapi dev main.py --port 8080"
#============prod=================
#command: sh -c "sleep 10s; fastapi run backend/main.py --proxy-headers --port 8080"
#============== Nginx Proxy Manager ====================================================================
mih-nginx:
container_name: mih-nginx
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- 8080:80
- '80:80' # Public HTTP
- '443:443' # Public HTTPS
- '127.0.0.1:81:81' # Admin Web Port
volumes:
- ./backend:/app
- ./mih_nginx/data:/data
- ./mih_nginx/letsencrypt:/etc/letsencrypt
networks:
- MIH-network
- mih-network
#============== GITEA ====================================================================
mih-gitea:
image: gitea/gitea:latest
container_name: mih-gitea
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=mysql
- GITEA__database__HOST=mih-gitea-db:3306
- GITEA__database__NAME=${GITEA_SQL_DB}
- GITEA__database__USER=${GITEA_SQL_USER}
- GITEA__database__PASSWD=${GITEA_SQL_PW}
restart: always
networks:
- mih-network
volumes:
- ./mih_git/gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "127.0.0.1:3000:3000"
- "127.0.0.1:222:22"
depends_on:
- mysqldb
#============== My SQL DB ====================================================================
mysqldb:
#build: ./database/
platform: linux/amd64
image: mysql:5.7
container_name: MIH-Database
mih-gitea-db:
condition: service_healthy
mih-gitea-db:
image: mysql:8.0
container_name: mih-gitea-db
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${SQL_ROOT_PW}
MYSQL_USER: ${SQL_USER}
MYSQL_PASSWORD: ${SQL_USER_PW}
MYSQL_DATABASE: ${SUPERTOKENS_DB}
- MYSQL_ROOT_PASSWORD=${GITEA_SQL_ROOT_PW}
- MYSQL_USER=${GITEA_SQL_USER}
- MYSQL_PASSWORD=${GITEA_SQL_PW}
- MYSQL_DATABASE=${GITEA_SQL_DB}
networks:
- MIH-network
ports:
- '3306:3306'
- mih-network
volumes:
- ./database:/var/lib/mysql
- ./mih_git/mysql:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
#============== Super Token Auth ====================================================================
supertokens:
container_name: MIH-SuperTokens
mih-supertokens:
container_name: mih-supertokens
image: supertokens/supertokens-mysql:latest
# image: registry.supertokens.io/supertokens/supertokens-mysql
depends_on:
- mysqldb
- mih-db
ports:
- 3567:3567
- '127.0.0.1:3567:3567'
environment:
REFRESH_TOKEN_VALIDITY: '604800'
ACCESS_TOKEN_VALIDITY: '86400'
PASSWORD_RESET_TOKEN_LIFETIME: '7200000'
MYSQL_USER: ${SQL_USER}
MYSQL_PASSWORD: ${SQL_USER_PW}
MYSQL_HOST: mysqldb
MYSQL_HOST: mih-db
MYSQL_PORT: 3306
MYSQL_DATABASE_NAME: ${SUPERTOKENS_DB}
API_KEYS: ${SUPERTOKENS_API_KEY}
networks:
- MIH-network
- mih-network
restart: unless-stopped
healthcheck:
test: >
@@ -64,104 +88,130 @@ services:
interval: 10s
timeout: 5s
retries: 5
#============== MIH WordPress ====================================================================
mih-wordpress:
container_name: mih-wordpress
image: wordpress
restart: always
ports:
- '127.0.0.1:8081:80'
environment:
WORDPRESS_DB_HOST: mih-wp-db
WORDPRESS_DB_USER: ${WP_SQL_USER}
WORDPRESS_DB_PASSWORD: ${WP_SQL_USER_PW}
WORDPRESS_DB_NAME: ${WP_SQL_DB}
volumes:
- ./mih_wp/ui:/var/www/html
networks:
- mih-network
mih-wp-db:
container_name: mih-wp-db
image: mariadb:10.11
restart: always
environment:
MARIADB_DATABASE: ${WP_SQL_DB}
MARIADB_USER: ${WP_SQL_USER}
MARIADB_PASSWORD: ${WP_SQL_USER_PW}
MARIADB_RANDOM_ROOT_PASSWORD: '1'
volumes:
- ./mih_wp/database:/var/lib/mysql
networks:
- mih-network
#============== MIH-UX Flutter ====================================================================
mih-ux:
container_name: mih-ux
build:
context: ./mih_ui
ports:
- "127.0.0.1:83:83"
networks:
- mih-network
depends_on:
- mih-api-hub
#============== API Hub ====================================================================
mih-api-hub:
build:
context: ./mih_api_hub
target: builder
container_name: mih-api-hub
ports:
- "127.0.0.1:8080:80"
volumes:
- ./mih_api_hub:/app
networks:
- mih-network
depends_on:
- mih-db
#============== My SQL DB ====================================================================
mih-db:
platform: linux/amd64
image: mysql:5.7
container_name: mih-db
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${SQL_ROOT_PW}
MYSQL_USER: ${SQL_USER}
MYSQL_PASSWORD: ${SQL_USER_PW}
MYSQL_DATABASE: ${SUPERTOKENS_DB}
networks:
- mih-network
ports:
- '127.0.0.1:3306:3306'
volumes:
- ./mih_db:/var/lib/mysql
#============== PHP My Admin ====================================================================
# phpmyadmin:
# platform: linux/amd64
# image: phpmyadmin/phpmyadmin
# container_name: MIH-phpmyadmin
# environment:
# PMA_HOST: mysqlDB
# PMA_HOST: mih-db
# PMA_PORT: 3306
# PMA_ARBITRARY:
# networks:
# - MIH-network
# - mih-network
# restart: always
# ports:
# - 8081:80
# depends_on:
# - mysqldb
#============== Nginx Proxy Server ====================================================================
nginx:
container_name: nginx
restart: unless-stopped
image: nginx
ports:
- 80:80
- 443:443
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- certbotConf:/etc/letsencrypt
- certbotChall:/var/www/certbot
depends_on:
- user-interface
networks:
- MIH-network
profiles: [ 'prod' ]
#============== MIH-UX Flutter ====================================================================
user-interface:
container_name: MIH-UX
build:
context: ./Frontend
ports:
- "83:83"
networks:
- MIH-network
depends_on:
- api
#============== Cert Bot ====================================================================
certbot:
image: certbot/certbot
container_name: certbot
volumes:
- certbotConf:/etc/letsencrypt
- certbotChall:/var/www/certbot
#command: certonly --test-cert --webroot -w /var/www/certbot --force-renewal --email yasienmeth@gmail.com -d mzansi-innovation-hub.co.za -d www.mzansi-innovation-hub.co.za --agree-tos
command: certonly --webroot -w /var/www/certbot --force-renewal --email ${CERTBOT_EMAIL} -d ${CERTBOT_APP_DOMAIN} -d ${CERTBOT_API_DOMAIN} -d ${CERTBOT_STORAGE_DOMAIN} -d ${CERTBOT_MONITOR_DOMAIN} -d ${CERTBOT_AI_DOMAIN} --agree-tos
networks:
- MIH-network
depends_on:
- nginx
profiles: [ 'withCert' ]
# - mih-db
#============== Minio File Storage ====================================================================
minio:
mih-minio:
platform: linux/amd64
container_name: MIH-Minio
hostname: minio
# image: docker.io/bitnami/minio:2022
container_name: mih-minio
hostname: mih-minio
image: minio/minio
ports:
- '9000:9000'
- '9001:9001'
- '127.0.0.1:9000:9000'
- '127.0.0.1:9001:9001'
volumes:
- './File_Storage:/data'
- './mih_minio:/data'
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PW}
# MINIO_SERVER_URL: ${MINIO_SERVER_URL}
networks:
- MIH-network
- mih-network
command: ["server", "/data", "--console-address", ":9001"]
#============== MIH-Monitor Portainer ====================================================================
portainer:
container_name: MIH-Monitor
mih-monitor:
container_name: mih-monitor
image: portainer/portainer-ce:2.20.3
ports:
- 9444:9443
- '127.0.0.1:9444:9443'
volumes:
- data:/data
- ./mih_monitor/data:/data
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
networks:
- MIH-network
- mih-network
#============== MIH-AI Ollama ====================================================================
ollama:
container_name: MIH-AI
mih-ai:
container_name: mih-ai
image: ollama/ollama:latest
ports:
- 11434:11434
- '127.0.0.1:11434:11434'
volumes:
# - ./Mzansi_AI:/code
- ./Mzansi_AI/ollama/ollama:/root/.ollama
- ./mih_ai/ollama/ollama:/root/.ollama
pull_policy: always
tty: true
restart: always
@@ -170,16 +220,16 @@ services:
- OLLAMA_KEEP_ALIVE=24h
- OLLAMA_HOST=0.0.0.0
networks:
- MIH-network
- mih-network
# === Added section for NVIDIA GPU acceleration ===
runtime: nvidia
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all # or specify a number of GPUs
capabilities: [ gpu ]
# runtime: nvidia
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all # or specify a number of GPUs
# capabilities: [ gpu ]
#============== Firebaase ====================================================================
# firebase:
# container_name: MIH-firebase-emulator
@@ -199,11 +249,3 @@ services:
# # - ./cache:/root/.cache/:rw
# # - ~/.config/:/root/.config
# - ./Firebase-emulator/firebase/data:/srv/firebase/data:rw
#============== Named Volumes ====================================================================
volumes:
certbotConf:
certbotChall:
data: #============== MIH Network ====================================================================
networks:
MIH-network:
driver: bridge

Binary file not shown.

4
mih_api_hub/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.env
__pycache__/
temp*.pdf
.DS_Store

View File

@@ -9,7 +9,7 @@ minioSecret = os.getenv("MINIO_SECRET_KEY")
def minioConnect(env):
if(env == "Dev"):
return Minio(
endpoint="minio:9000",
endpoint="mih-minio:9000",
# "minio.mzansi-innovation-hub.co.za",
access_key=minioAccess,
secret_key=minioSecret,
@@ -17,7 +17,7 @@ def minioConnect(env):
)
else:
return Minio(
# endpoint="minio:9000",
# endpoint="mih-minio:9000",
endpoint="minio.mzansi-innovation-hub.co.za",
access_key=minioAccess,
secret_key=minioSecret,

View File

@@ -34,28 +34,36 @@ from supertokens_python.recipe.session.framework.fastapi import verify_session
from supertokens_python.recipe.emailverification import EmailVerificationClaim
from supertokens_python.recipe.session import SessionContainer
import os
from dotenv import load_dotenv
load_dotenv()
st_api_key = os.getenv("SUPERTOKENS_API_KEY")
origins = [
"http://localhost",
"http://localhost:80",
"http://localhost:1995",
"http://localhost:8080",
"http://MIH-API-Hub:80",
"http://MIH-API-Hub",
"http://api.mzansi-innovation-hub.co.za",
"*",
"http://app.mzansi-innovation-hub.co.za",
"https://api.mzansi-innovation-hub.co.za",
"https://app.mzansi-innovation-hub.co.za",
]
init(
app_info=InputAppInfo(
app_name="Mzansi Innovation Hub",
api_domain="http://localhost:8080/",
website_domain="http://app.mzansi-innovation-hub.co.za",
website_domain="https://app.mzansi-innovation-hub.co.za",
api_base_path="/auth",
website_base_path="/auth"
),
supertokens_config=SupertokensConfig(
# https://try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
connection_uri="http://MIH-SuperTokens:3567/",
api_key="leatucczyixqwkqqdrhayiwzeofkltds"
connection_uri="http://mih-supertokens:3567/",
api_key=st_api_key
),
framework='fastapi',
recipe_list=[

View File

@@ -8,7 +8,7 @@ dbPass = os.getenv("DB_PASSWD")
def dbPatientManagerConnect():
return mysql.connector.connect(
host="mysqldb",
host="mih-db",
user=dbUser,
passwd=dbPass,
database="patient_manager"
@@ -16,7 +16,7 @@ def dbPatientManagerConnect():
def dbAppDataConnect():
return mysql.connector.connect(
host="mysqldb",
host="mih-db",
user=dbUser,
passwd=dbPass,
database="app_data"
@@ -24,7 +24,7 @@ def dbAppDataConnect():
def dbDataAccessConnect():
return mysql.connector.connect(
host="mysqldb",
host="mih-db",
user=dbUser,
passwd=dbPass,
database="data_access"
@@ -32,7 +32,7 @@ def dbDataAccessConnect():
def dbMzansiWalletConnect():
return mysql.connector.connect(
host="mysqldb",
host="mih-db",
user=dbUser,
passwd=dbPass,
database="mzansi_wallet"
@@ -40,7 +40,7 @@ def dbMzansiWalletConnect():
def dbMzansiDirectoryConnect():
return mysql.connector.connect(
host="mysqldb",
host="mih-db",
user=dbUser,
passwd=dbPass,
database="mzansi_directory"
@@ -48,7 +48,7 @@ def dbMzansiDirectoryConnect():
def dbMzansiCalendarConnect():
return mysql.connector.connect(
host="mysqldb",
host="mih-db",
user=dbUser,
passwd=dbPass,
database="mzansi_calendar"
@@ -56,7 +56,7 @@ def dbMzansiCalendarConnect():
def dbAllConnect():
return mysql.connector.connect(
host="mysqldb",
host="mih-db",
user=dbUser,
passwd=dbPass,
)

View File

@@ -7,7 +7,7 @@ from dotenv import load_dotenv
load_dotenv()
dbUser = os.getenv("DB_USER")
dbPass = os.getenv("DB_PASSWD")
dbHost = "mysqldb"
dbHost = "mih-db"
dbPort = 3306
encoded_dbPass = quote_plus(dbPass)
base_connect_url = f"mysql+mysqlconnector://{dbUser}:{encoded_dbPass}@{dbHost}:{dbPort}/"
@@ -15,7 +15,7 @@ base_connect_url = f"mysql+mysqlconnector://{dbUser}:{encoded_dbPass}@{dbHost}:{
def dbPatientManagerConnect():
return create_engine(base_connect_url+"patient_manager", echo=False, pool_recycle=3600)
# return mysql.connector.connect(
# host="mysqldb",
# host="mih-db",
# user=dbUser,
# passwd=dbPass,
# database="patient_manager"
@@ -24,7 +24,7 @@ def dbPatientManagerConnect():
def dbAppDataConnect():
return create_engine(base_connect_url+"app_data", echo=False, pool_recycle=3600)
# return mysql.connector.connect(
# host="mysqldb",
# host="mih-db",
# user=dbUser,
# passwd=dbPass,
# database="app_data"
@@ -33,7 +33,7 @@ def dbAppDataConnect():
def dbDataAccessConnect():
return create_engine(base_connect_url+"data_access", echo=False, pool_recycle=3600)
# return mysql.connector.connect(
# host="mysqldb",
# host="mih-db",
# user=dbUser,
# passwd=dbPass,
# database="data_access"
@@ -42,7 +42,7 @@ def dbDataAccessConnect():
def dbMzansiWalletConnect():
return create_engine(base_connect_url+"mzansi_wallet", echo=False, pool_recycle=3600)
# return mysql.connector.connect(
# host="mysqldb",
# host="mih-db",
# user=dbUser,
# passwd=dbPass,
# database="mzansi_wallet"
@@ -51,7 +51,7 @@ def dbMzansiWalletConnect():
def dbMzansiDirectoryConnect():
return create_engine(base_connect_url+"mzansi_directory", echo=False, pool_recycle=3600)
# return mysql.connector.connect(
# host="mysqldb",
# host="mih-db",
# user=dbUser,
# passwd=dbPass,
# database="mzansi_directory"
@@ -60,7 +60,7 @@ def dbMzansiDirectoryConnect():
def dbMzansiCalendarConnect():
return create_engine(base_connect_url+"mzansi_calendar", echo=False, pool_recycle=3600)
# return mysql.connector.connect(
# host="mysqldb",
# host="mih-db",
# user=dbUser,
# passwd=dbPass,
# database="mzansi_calendar"
@@ -69,7 +69,7 @@ def dbMzansiCalendarConnect():
def dbAllConnect():
return create_engine(base_connect_url, echo=False, pool_recycle=3600)
# return mysql.connector.connect(
# host="mysqldb",
# host="mih-db",
# user=dbUser,
# passwd=dbPass,
# )

View File

@@ -9,4 +9,5 @@ watchfiles
python-multipart
python-dotenv
xlrd
supertokens-python==0.29.2
supertokens-python==0.24.0
sniffio

View File

Some files were not shown because too many files have changed in this diff Show More