Compare commits
No commits in common. "main" and "0.1.0" have entirely different histories.
137
Jenkinsfile
vendored
137
Jenkinsfile
vendored
@ -1,137 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
stages {
|
|
||||||
stage('Flutter Cleanup/Update') {
|
|
||||||
steps {
|
|
||||||
sh '''cd fbla_ui
|
|
||||||
flutter upgrade --force
|
|
||||||
flutter pub upgrade
|
|
||||||
flutter --version
|
|
||||||
flutter doctor
|
|
||||||
flutter clean'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Build API & UI') {
|
|
||||||
parallel {
|
|
||||||
stage('Build API') {
|
|
||||||
steps {
|
|
||||||
sh '''cd fbla-api
|
|
||||||
docker image prune -f
|
|
||||||
docker build --no-cache -t fbla-api .'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('UI Web Build') {
|
|
||||||
steps {
|
|
||||||
sh '''cd fbla_ui
|
|
||||||
flutter build web --release --base-href /fbla/'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('UI Linux Build') {
|
|
||||||
steps {
|
|
||||||
sh '''cd fbla_ui
|
|
||||||
flutter build linux --release'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('UI APK Build') {
|
|
||||||
steps {
|
|
||||||
sh '''cd fbla_ui
|
|
||||||
flutter build apk --release'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Deploy and Save') {
|
|
||||||
parallel {
|
|
||||||
stage('Save Other Builds') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def remote = [
|
|
||||||
name : 'HostServer',
|
|
||||||
host : '192.168.0.216',
|
|
||||||
user : "${env.JOBLINK_LOCAL_USER}",
|
|
||||||
password : "${env.JOBLINK_LOCAL_PASSWD}",
|
|
||||||
allowAnyHosts: true,
|
|
||||||
]
|
|
||||||
if (env.BRANCH_NAME == 'main') {
|
|
||||||
sshRemove(path: "/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux"
|
|
||||||
sshPut(from: 'fbla_ui/build/linux/x64/release', into: "/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux"
|
|
||||||
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/"
|
|
||||||
sshRemove(path: "/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk"
|
|
||||||
sshPut(from: 'fbla_ui/build/app/outputs/apk/release', into: "/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk"
|
|
||||||
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/"
|
|
||||||
} else {
|
|
||||||
sshRemove(path: "/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux"
|
|
||||||
sshPut(from: 'fbla_ui/build/linux/x64/release', into: "/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux"
|
|
||||||
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/"
|
|
||||||
sshRemove(path: "/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk"
|
|
||||||
sshPut(from: 'fbla_ui/build/app/outputs/apk/release', into: "/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk"
|
|
||||||
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Deploy Remote Web UI') {
|
|
||||||
when {
|
|
||||||
expression {
|
|
||||||
env.BRANCH_NAME == 'main'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def remote = [
|
|
||||||
name : 'MarinoDev',
|
|
||||||
host : 'marinodev.com',
|
|
||||||
port : 21098,
|
|
||||||
user : "${env.JOBLINK_REMOTE_USER}",
|
|
||||||
identityFile : '/var/jenkins_home/marinoDevPrivateKey',
|
|
||||||
passphrase : "${env.JOBLINK_REMOTE_PASSWD}",
|
|
||||||
allowAnyHosts: true,
|
|
||||||
]
|
|
||||||
sshRemove(path: "/home/${env.JOBLINK_REMOTE_USER}/public_html/fbla", remote: remote)
|
|
||||||
sshPut(from: 'fbla_ui/build/web/', into: "/home/${env.JOBLINK_REMOTE_USER}/public_html/", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_REMOTE_USER}/public_html/web /home/${env.JOBLINK_REMOTE_USER}/public_html/fbla"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Deploy Local Web UI') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def remote = [
|
|
||||||
name : 'HostServer',
|
|
||||||
host : '192.168.0.216',
|
|
||||||
user : "${env.JOBLINK_LOCAL_USER}",
|
|
||||||
password : "${env.JOBLINK_LOCAL_PASSWD}",
|
|
||||||
allowAnyHosts: true,
|
|
||||||
]
|
|
||||||
sshRemove(path: "/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla", remote: remote)
|
|
||||||
sshPut(from: 'fbla_ui/build/web/', into: "/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver", remote: remote)
|
|
||||||
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/web /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Start API') {
|
|
||||||
steps {
|
|
||||||
sh '''cd fbla-api
|
|
||||||
docker-compose down
|
|
||||||
docker-compose up -d'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Run API Tests') {
|
|
||||||
steps {
|
|
||||||
sh '''cd fbla-api
|
|
||||||
dart pub get
|
|
||||||
dart run ./test/fbla_api_test.dart'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
76
README.md
76
README.md
@ -1,75 +1,5 @@
|
|||||||
# Job Link
|
This is my app `Job Link` for the 2023-2024 FBLA Coding and Programming event.
|
||||||
|
|
||||||
This is my app `Job Link` for the 2023-2024 FBLA Coding and Programming event.\
|
It uses the [Flutter Framework](https://flutter.dev/) for the front end and [Dart Language](https://dart.dev/) for both the front end and API.
|
||||||
WI SLC Winner.
|
|
||||||
|
|
||||||
It uses the [Flutter Framework](https://flutter.dev/) for the front end and
|
Please view the README in [fbla_ui](fbla_ui/README.md) and [fbla-api](fbla-api/README.md) for specific instructions for installation and usage for each part of the app
|
||||||
the [Dart Language](https://dart.dev/) for both the front end and API.
|
|
||||||
|
|
||||||
## 3rd Party Libraries
|
|
||||||
|
|
||||||
- [dart_jsonwebtoken](https://pub.dev/packages/dart_jsonwebtoken)
|
|
||||||
- [sliver_tools](https://pub.dev/packages/sliver_tools)
|
|
||||||
- [flutter_sticky_header](https://pub.dev/packages/flutter_sticky_header)
|
|
||||||
- [pdf](https://pub.dev/packages/pdf)
|
|
||||||
- [printing](https://pub.dev/packages/printing)
|
|
||||||
- [open_filex](https://pub.dev/packages/open_filex)
|
|
||||||
- [postgres](https://pub.dev/packages/postgres)
|
|
||||||
- [argon2](https://pub.dev/packages/argon2)
|
|
||||||
- [rive](https://pub.dev/packages/rive)
|
|
||||||
|
|
||||||
[Clearbit's logo API](https://clearbit.com/logo) was also used to get logos for businesses.
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
### Job Link
|
|
||||||
|
|
||||||
- **OS**: Windows, Linux, MacOS, Android, IOS. Note that some releases may not contain a MacOS or
|
|
||||||
IOS build.
|
|
||||||
- Stable internet connection.
|
|
||||||
|
|
||||||
### API
|
|
||||||
|
|
||||||
- **OS**: Windows, Linux, MacOS.
|
|
||||||
- Stable internet connection.
|
|
||||||
|
|
||||||
## Installation/Usage
|
|
||||||
|
|
||||||
Please view the README in [fbla_ui](fbla_ui/README.md) and [fbla-api](fbla-api/README.md) for
|
|
||||||
specific instructions for installation and usage for each part of the app.
|
|
||||||
|
|
||||||
## Competitions
|
|
||||||
|
|
||||||
[Here](https://docs.google.com/presentation/d/1ZbSE9RqobU2T-NDIm3CUtT_9nEhOm3_B47NZl1-c_QA) is the
|
|
||||||
presentation used for competitions.
|
|
||||||
|
|
||||||
### WI State Leadership Conference
|
|
||||||
|
|
||||||
1st Place\
|
|
||||||
Used release 0.1.1\
|
|
||||||
[Here](SLC) are my score sheets.
|
|
||||||
|
|
||||||
Questions asked (with my answers):
|
|
||||||
|
|
||||||
**Q**: Why did you decide to use the apps (framework and tools I assume) you used?\
|
|
||||||
**A**: I decided to use Flutter primarily because of its cross-platform capabilities and its
|
|
||||||
integration with the [Material design specification](https://m3.material.io/). I also decided to use
|
|
||||||
it because I had some previous experience with Flutter and Dart, and Dart is somewhat similar to
|
|
||||||
Java which I also had experience with.
|
|
||||||
|
|
||||||
This one seems to just be a clarification for the `User input is validated` category of
|
|
||||||
the [scoring sheet](https://connect.fbla.org/headquarters/files/High%20School%20Competitive%20Events%20Resources/Individual%20Guidelines/Presentation%20Events/Coding--Programming.pdf) (
|
|
||||||
page 5-6)\
|
|
||||||
**Q**: You mentioned that you validated that the description [of the business] is required, do you
|
|
||||||
validate all the inputs or just that?\
|
|
||||||
**A**: I validate that all of the required fields are inputted, and I also check for a valid email
|
|
||||||
address and website format.
|
|
||||||
|
|
||||||
This seems to be for
|
|
||||||
the [scoring sheet](https://connect.fbla.org/headquarters/files/High%20School%20Competitive%20Events%20Resources/Individual%20Guidelines/Presentation%20Events/Coding--Programming.pdf) (
|
|
||||||
page 5-6) `Code Quality` section.\
|
|
||||||
While looking through a binder of the presentation and source code:\
|
|
||||||
**Q**: Is your source code all properly commented?\
|
|
||||||
**A**: While it is hard to comment UI code because of the nature of it, I did my best to use
|
|
||||||
comments where applicable, and I also provide extensive documentation of the installation and usage
|
|
||||||
of the app in the documentation in the README files.
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -9,7 +9,7 @@ RUN echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storag
|
|||||||
RUN apt-get update && apt-get install -y dart
|
RUN apt-get update && apt-get install -y dart
|
||||||
ENV PATH="$PATH:/usr/lib/dart/bin"
|
ENV PATH="$PATH:/usr/lib/dart/bin"
|
||||||
|
|
||||||
RUN cd /root && git clone https://git.marinodev.com/MarinoDev/FBLA24.git
|
RUN cd /root && git clone https://https://git.marinodev.com/MarinoDev/FBLA24.git
|
||||||
WORKDIR /root/FBLA24/fbla-api
|
WORKDIR /root/FBLA24/fbla-api
|
||||||
RUN dart pub install
|
RUN dart pub install
|
||||||
|
|
||||||
|
|||||||
1
fbla-api/Jenkinsfile
vendored
1
fbla-api/Jenkinsfile
vendored
@ -16,5 +16,6 @@ docker-compose up -d'''
|
|||||||
dart run ./test/fbla_api_test.dart'''
|
dart run ./test/fbla_api_test.dart'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,19 +2,19 @@ This is the API for my 2023-2024 FBLA Coding & Programming App
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Install [Dart SDK](https://dart.dev/get-dart).
|
1. Install [Dart SDK](https://dart.dev/get-dart)
|
||||||
2. Clone the repo .
|
2. Install [PostgreSQL](https://www.postgresql.org/) and set it up
|
||||||
|
3. Clone the repo
|
||||||
```bash
|
```
|
||||||
git clone https://git.marinodev.com/MarinoDev/FBLA24.git
|
git clone https://git.marinodev.com/MarinoDev/FBLA24.git
|
||||||
cd FBLA24/fbla-api/
|
cd FBLA24/fbla-api/
|
||||||
```
|
```
|
||||||
|
4. Run `dart pub install` to install dart packages
|
||||||
|
|
||||||
3. Run `dart pub install` to install dart packages.
|
## Usage
|
||||||
4. Install [PostgreSQL](https://www.postgresql.org/) and set it up.
|
|
||||||
5. Create `fbla` database in postgres.
|
|
||||||
|
|
||||||
```SQL
|
1. Create `fbla` database in postgres
|
||||||
|
```
|
||||||
CREATE DATABASE fbla
|
CREATE DATABASE fbla
|
||||||
WITH
|
WITH
|
||||||
OWNER = [username]
|
OWNER = [username]
|
||||||
@ -22,12 +22,10 @@ CREATE DATABASE fbla
|
|||||||
CONNECTION LIMIT = -1
|
CONNECTION LIMIT = -1
|
||||||
IS_TEMPLATE = False;
|
IS_TEMPLATE = False;
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure to change [username] to the actual username of your postgres instance.
|
Make sure to change [username] to the actual username of your postgres instance.
|
||||||
|
|
||||||
6. Create `businesses` table.
|
2. Create `businesses` table
|
||||||
|
```
|
||||||
```SQL
|
|
||||||
-- Table: public.businesses
|
-- Table: public.businesses
|
||||||
|
|
||||||
-- DROP TABLE IF EXISTS public.businesses;
|
-- DROP TABLE IF EXISTS public.businesses;
|
||||||
@ -53,40 +51,10 @@ TABLESPACE pg_default;
|
|||||||
ALTER TABLE IF EXISTS public.businesses
|
ALTER TABLE IF EXISTS public.businesses
|
||||||
OWNER to [username];
|
OWNER to [username];
|
||||||
```
|
```
|
||||||
|
Make sure to change [username] to the actual username of your postgres instance
|
||||||
|
|
||||||
Make sure to change [username] to the actual username of your postgres instance.
|
3. Create `users` table
|
||||||
|
|
||||||
7. Create `listings` table.
|
|
||||||
|
|
||||||
```SQL
|
|
||||||
-- Table: public.listings
|
|
||||||
|
|
||||||
-- DROP TABLE IF EXISTS public.listings;
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS public.listings
|
|
||||||
(
|
|
||||||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
|
|
||||||
"businessId" integer NOT NULL,
|
|
||||||
name text COLLATE pg_catalog."default" NOT NULL,
|
|
||||||
description text COLLATE pg_catalog."default" NOT NULL,
|
|
||||||
type text COLLATE pg_catalog."default" NOT NULL,
|
|
||||||
wage text COLLATE pg_catalog."default",
|
|
||||||
link text COLLATE pg_catalog."default",
|
|
||||||
"offerType" text COLLATE pg_catalog."default" NOT NULL,
|
|
||||||
CONSTRAINT listing_pkey PRIMARY KEY (id)
|
|
||||||
)
|
|
||||||
|
|
||||||
TABLESPACE pg_default;
|
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS public.listings
|
|
||||||
OWNER to [username];
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure to change [username] to the actual username of your postgres instance.
|
|
||||||
|
|
||||||
8. Create `users` table.
|
|
||||||
|
|
||||||
```SQL
|
|
||||||
-- Table: public.users
|
-- Table: public.users
|
||||||
|
|
||||||
-- DROP TABLE IF EXISTS public.users;
|
-- DROP TABLE IF EXISTS public.users;
|
||||||
@ -103,37 +71,11 @@ CREATE TABLE IF NOT EXISTS public.users
|
|||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE IF EXISTS public.users
|
ALTER TABLE IF EXISTS public.users
|
||||||
OWNER to [username];
|
OWNER to postgres;
|
||||||
```
|
```
|
||||||
|
4. Set environment variables `POSTGRES_ADDRESS` (IP address), `POSTGRES_PORT` (default 5432), `POSTGRES_USERNAME`, and `POSTGRES_PASSWORD` to appropriate information for your postgres database. Also set `SECRET_KEY` to anything you want to genera te JSON Web Tokens.
|
||||||
Make sure to change [username] to the actual username of your postgres instance.
|
5. Set lib/create_first_user.dart username and password variables at top of file and run with `dart run lib/create_first_user.dart`
|
||||||
|
Note: the username and password you use here will be what you use to log into the app as an admin
|
||||||
8. Set environment variables `JOBLINK_POSTGRES_ADDRESS` (IP address), `JOBLINK_POSTGRES_PORT` (
|
6. Your database should be all set up! Start the API with `dart run lib/fbla_api.dart` or alternatively, run it in a docker container with [Docker Build](https://docs.docker.com/reference/cli/docker/image/build/) and [Docker Compose](https://docs.docker.com/compose/) using the included [Dockerfile](Dockerfile) and [docker-compose.yml](docker-compose.yml) files. If using `Docker Compose`, change the first portion of the volumes path on line 9 to any desired storage location.
|
||||||
default 5432), `JOBLINK_POSTGRES_USERNAME`, and `JOBLINK_POSTGRES_PASSWORD` to appropriate
|
|
||||||
information for your postgres database. Also set `JOBLINK_SECRET_KEY` to anything you want to
|
|
||||||
generate JSON Web Tokens.
|
|
||||||
9. Set lib/create_first_user.dart username and password variables at top of file and run
|
|
||||||
with `dart run lib/create_first_user.dart`.\
|
|
||||||
Note: the username and password you use here will be what you use to log into the app as an
|
|
||||||
admin.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Installed
|
|
||||||
|
|
||||||
Start the API with `dart run lib/fbla_api.dart`\
|
|
||||||
Note the address it is serving at, you will need this to connect it to the UI, and to run tests.
|
Note the address it is serving at, you will need this to connect it to the UI, and to run tests.
|
||||||
|
7. Test your api with `dart run test/fbla_api_test.dart`, setting `apiAddress` on line 8 to your api address.
|
||||||
### Docker
|
|
||||||
|
|
||||||
Run it in a docker container
|
|
||||||
with [Docker Build](https://docs.docker.com/reference/cli/docker/image/build/)
|
|
||||||
and [Docker Compose](https://docs.docker.com/compose/) using the included [Dockerfile](Dockerfile)
|
|
||||||
and [docker-compose.yml](docker-compose.yml) files. If using `Docker Compose`, change the first
|
|
||||||
portion of the volumes path on line 9 to any desired storage location.\
|
|
||||||
Note the address it is serving at, you will need this to connect it to the UI, and to run tests.
|
|
||||||
|
|
||||||
### Testing
|
|
||||||
|
|
||||||
You can test all functionality of your api with `dart run test/fbla_api_test.dart`,
|
|
||||||
setting `apiAddress` on line 8 to your api address.
|
|
||||||
|
|||||||
25
fbla-api/certificates/cert.pem
Normal file
25
fbla-api/certificates/cert.pem
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIEQzCCAyugAwIBAgISA1MOaRzFLZim3nvjG7iscMdEMA0GCSqGSIb3DQEBCwUA
|
||||||
|
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
|
||||||
|
EwJSMzAeFw0yMzEyMTQyMjI5NTVaFw0yNDAzMTMyMjI5NTRaMCAxHjAcBgNVBAMT
|
||||||
|
FWhvbWVsYWIubWFyaW5vZGV2LmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA
|
||||||
|
BER7NDX7FANFf72Pqwl5haoczQchiOhMGNyMa5foT0aYG2DeMQeEhpl+17vBzEwu
|
||||||
|
KewujegQNWZdNHVbGxqdUmWjggIuMIICKjAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0l
|
||||||
|
BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYE
|
||||||
|
FOsys6fx3sqsaEaqklTWasLzlNJzMB8GA1UdIwQYMBaAFBQusxe3WFbLrlAJQOYf
|
||||||
|
r52LFMLGMFUGCCsGAQUFBwEBBEkwRzAhBggrBgEFBQcwAYYVaHR0cDovL3IzLm8u
|
||||||
|
bGVuY3Iub3JnMCIGCCsGAQUFBzAChhZodHRwOi8vcjMuaS5sZW5jci5vcmcvMDgG
|
||||||
|
A1UdEQQxMC+CFWhvbWVsYWIubWFyaW5vZGV2LmNvbYIWbWFyaW5vLW5hcy5zeW5v
|
||||||
|
bG9neS5tZTATBgNVHSAEDDAKMAgGBmeBDAECATCCAQMGCisGAQQB1nkCBAIEgfQE
|
||||||
|
gfEA7wB2AEiw42vapkc0D+VqAvqdMOscUgHLVt0sgdm7v6s52IRzAAABjGqqUTkA
|
||||||
|
AAQDAEcwRQIhAJncD2v9CgQii1KCLJhILJ96Jy7mE3a1ptaZ8sip8k3xAiBXw7ML
|
||||||
|
wbp/ikIzl0xYTeJsjU7lp7/VI26K+luw++dsMgB1AO7N0GTV2xrOxVy3nbTNE6Iy
|
||||||
|
h0Z8vOzew1FIWUZxH7WbAAABjGqqUTsAAAQDAEYwRAIgSXZW95Cafz5olbebYbSH
|
||||||
|
xlvPXhmJaspB7XzEsQP2i6kCIHa1QcGg9vyXJ6apl7WSPIz4DLJb6/ZeaHkPqAC5
|
||||||
|
NjKPMA0GCSqGSIb3DQEBCwUAA4IBAQBSKsqvA8v8h1WmTjudd8cRWc3RdU6lgq/E
|
||||||
|
pTXX6XWYFpU+D7jprp/NeW8RmVToQRUi6A3Bv9KnrsHG5HpwJ37SLh6Gv8s2t1A/
|
||||||
|
8FyNyndjuBKxFSaoJKkqlKUA657dXh67if5WLZYZYQdArRw3Q+fQOfSit8+RomTY
|
||||||
|
xmNVnRVO5+JRwxwbk/WT8tZHOb3Cd7Ozo7d2vpwH/KqY4RM7ajV8shzulMlAtqfT
|
||||||
|
ahi4ph8eUm43nCJPsVa4ddQLaV4z8EXoQ/SAsjrMkbAyg4G3uKoCqPUX4lnvqAAW
|
||||||
|
7kxmH8lJpkh76sz7gT1j/vzk9Fbslk3+8oa8PUO9PYQWfYwzWIs2
|
||||||
|
-----END CERTIFICATE-----
|
||||||
61
fbla-api/certificates/chain.pem
Normal file
61
fbla-api/certificates/chain.pem
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFFjCCAv6gAwIBAgIRAJErCErPDBinU/bWLiWnX1owDQYJKoZIhvcNAQELBQAw
|
||||||
|
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||||
|
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMjAwOTA0MDAwMDAw
|
||||||
|
WhcNMjUwOTE1MTYwMDAwWjAyMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg
|
||||||
|
RW5jcnlwdDELMAkGA1UEAxMCUjMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
|
||||||
|
AoIBAQC7AhUozPaglNMPEuyNVZLD+ILxmaZ6QoinXSaqtSu5xUyxr45r+XXIo9cP
|
||||||
|
R5QUVTVXjJ6oojkZ9YI8QqlObvU7wy7bjcCwXPNZOOftz2nwWgsbvsCUJCWH+jdx
|
||||||
|
sxPnHKzhm+/b5DtFUkWWqcFTzjTIUu61ru2P3mBw4qVUq7ZtDpelQDRrK9O8Zutm
|
||||||
|
NHz6a4uPVymZ+DAXXbpyb/uBxa3Shlg9F8fnCbvxK/eG3MHacV3URuPMrSXBiLxg
|
||||||
|
Z3Vms/EY96Jc5lP/Ooi2R6X/ExjqmAl3P51T+c8B5fWmcBcUr2Ok/5mzk53cU6cG
|
||||||
|
/kiFHaFpriV1uxPMUgP17VGhi9sVAgMBAAGjggEIMIIBBDAOBgNVHQ8BAf8EBAMC
|
||||||
|
AYYwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMBMBIGA1UdEwEB/wQIMAYB
|
||||||
|
Af8CAQAwHQYDVR0OBBYEFBQusxe3WFbLrlAJQOYfr52LFMLGMB8GA1UdIwQYMBaA
|
||||||
|
FHm0WeZ7tuXkAXOACIjIGlj26ZtuMDIGCCsGAQUFBwEBBCYwJDAiBggrBgEFBQcw
|
||||||
|
AoYWaHR0cDovL3gxLmkubGVuY3Iub3JnLzAnBgNVHR8EIDAeMBygGqAYhhZodHRw
|
||||||
|
Oi8veDEuYy5sZW5jci5vcmcvMCIGA1UdIAQbMBkwCAYGZ4EMAQIBMA0GCysGAQQB
|
||||||
|
gt8TAQEBMA0GCSqGSIb3DQEBCwUAA4ICAQCFyk5HPqP3hUSFvNVneLKYY611TR6W
|
||||||
|
PTNlclQtgaDqw+34IL9fzLdwALduO/ZelN7kIJ+m74uyA+eitRY8kc607TkC53wl
|
||||||
|
ikfmZW4/RvTZ8M6UK+5UzhK8jCdLuMGYL6KvzXGRSgi3yLgjewQtCPkIVz6D2QQz
|
||||||
|
CkcheAmCJ8MqyJu5zlzyZMjAvnnAT45tRAxekrsu94sQ4egdRCnbWSDtY7kh+BIm
|
||||||
|
lJNXoB1lBMEKIq4QDUOXoRgffuDghje1WrG9ML+Hbisq/yFOGwXD9RiX8F6sw6W4
|
||||||
|
avAuvDszue5L3sz85K+EC4Y/wFVDNvZo4TYXao6Z0f+lQKc0t8DQYzk1OXVu8rp2
|
||||||
|
yJMC6alLbBfODALZvYH7n7do1AZls4I9d1P4jnkDrQoxB3UqQ9hVl3LEKQ73xF1O
|
||||||
|
yK5GhDDX8oVfGKF5u+decIsH4YaTw7mP3GFxJSqv3+0lUFJoi5Lc5da149p90Ids
|
||||||
|
hCExroL1+7mryIkXPeFM5TgO9r0rvZaBFOvV2z0gp35Z0+L4WPlbuEjN/lxPFin+
|
||||||
|
HlUjr8gRsI3qfJOQFy/9rKIJR0Y/8Omwt/8oTWgy1mdeHmmjk7j1nYsvC9JSQ6Zv
|
||||||
|
MldlTTKB3zhThV1+XWYp6rjd5JW1zbVWEkLNxE7GJThEUG3szgBVGP7pSWTUTsqX
|
||||||
|
nLRbwHOoq7hHwg==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFYDCCBEigAwIBAgIQQAF3ITfU6UK47naqPGQKtzANBgkqhkiG9w0BAQsFADA/
|
||||||
|
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||||
|
DkRTVCBSb290IENBIFgzMB4XDTIxMDEyMDE5MTQwM1oXDTI0MDkzMDE4MTQwM1ow
|
||||||
|
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||||
|
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwggIiMA0GCSqGSIb3DQEB
|
||||||
|
AQUAA4ICDwAwggIKAoICAQCt6CRz9BQ385ueK1coHIe+3LffOJCMbjzmV6B493XC
|
||||||
|
ov71am72AE8o295ohmxEk7axY/0UEmu/H9LqMZshftEzPLpI9d1537O4/xLxIZpL
|
||||||
|
wYqGcWlKZmZsj348cL+tKSIG8+TA5oCu4kuPt5l+lAOf00eXfJlII1PoOK5PCm+D
|
||||||
|
LtFJV4yAdLbaL9A4jXsDcCEbdfIwPPqPrt3aY6vrFk/CjhFLfs8L6P+1dy70sntK
|
||||||
|
4EwSJQxwjQMpoOFTJOwT2e4ZvxCzSow/iaNhUd6shweU9GNx7C7ib1uYgeGJXDR5
|
||||||
|
bHbvO5BieebbpJovJsXQEOEO3tkQjhb7t/eo98flAgeYjzYIlefiN5YNNnWe+w5y
|
||||||
|
sR2bvAP5SQXYgd0FtCrWQemsAXaVCg/Y39W9Eh81LygXbNKYwagJZHduRze6zqxZ
|
||||||
|
Xmidf3LWicUGQSk+WT7dJvUkyRGnWqNMQB9GoZm1pzpRboY7nn1ypxIFeFntPlF4
|
||||||
|
FQsDj43QLwWyPntKHEtzBRL8xurgUBN8Q5N0s8p0544fAQjQMNRbcTa0B7rBMDBc
|
||||||
|
SLeCO5imfWCKoqMpgsy6vYMEG6KDA0Gh1gXxG8K28Kh8hjtGqEgqiNx2mna/H2ql
|
||||||
|
PRmP6zjzZN7IKw0KKP/32+IVQtQi0Cdd4Xn+GOdwiK1O5tmLOsbdJ1Fu/7xk9TND
|
||||||
|
TwIDAQABo4IBRjCCAUIwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
|
||||||
|
SwYIKwYBBQUHAQEEPzA9MDsGCCsGAQUFBzAChi9odHRwOi8vYXBwcy5pZGVudHJ1
|
||||||
|
c3QuY29tL3Jvb3RzL2RzdHJvb3RjYXgzLnA3YzAfBgNVHSMEGDAWgBTEp7Gkeyxx
|
||||||
|
+tvhS5B1/8QVYIWJEDBUBgNVHSAETTBLMAgGBmeBDAECATA/BgsrBgEEAYLfEwEB
|
||||||
|
ATAwMC4GCCsGAQUFBwIBFiJodHRwOi8vY3BzLnJvb3QteDEubGV0c2VuY3J5cHQu
|
||||||
|
b3JnMDwGA1UdHwQ1MDMwMaAvoC2GK2h0dHA6Ly9jcmwuaWRlbnRydXN0LmNvbS9E
|
||||||
|
U1RST09UQ0FYM0NSTC5jcmwwHQYDVR0OBBYEFHm0WeZ7tuXkAXOACIjIGlj26Ztu
|
||||||
|
MA0GCSqGSIb3DQEBCwUAA4IBAQAKcwBslm7/DlLQrt2M51oGrS+o44+/yQoDFVDC
|
||||||
|
5WxCu2+b9LRPwkSICHXM6webFGJueN7sJ7o5XPWioW5WlHAQU7G75K/QosMrAdSW
|
||||||
|
9MUgNTP52GE24HGNtLi1qoJFlcDyqSMo59ahy2cI2qBDLKobkx/J3vWraV0T9VuG
|
||||||
|
WCLKTVXkcGdtwlfFRjlBz4pYg1htmf5X6DYO8A4jqv2Il9DjXA6USbW1FzXSLr9O
|
||||||
|
he8Y4IWS6wY7bCkjCWDcRQJMEhg76fsO3txE+FiYruq9RUWhiF1myv4Q6W+CyBFC
|
||||||
|
Dfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5
|
||||||
|
-----END CERTIFICATE-----
|
||||||
86
fbla-api/certificates/fullchain.pem
Normal file
86
fbla-api/certificates/fullchain.pem
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIEQzCCAyugAwIBAgISA1MOaRzFLZim3nvjG7iscMdEMA0GCSqGSIb3DQEBCwUA
|
||||||
|
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
|
||||||
|
EwJSMzAeFw0yMzEyMTQyMjI5NTVaFw0yNDAzMTMyMjI5NTRaMCAxHjAcBgNVBAMT
|
||||||
|
FWhvbWVsYWIubWFyaW5vZGV2LmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA
|
||||||
|
BER7NDX7FANFf72Pqwl5haoczQchiOhMGNyMa5foT0aYG2DeMQeEhpl+17vBzEwu
|
||||||
|
KewujegQNWZdNHVbGxqdUmWjggIuMIICKjAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0l
|
||||||
|
BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYE
|
||||||
|
FOsys6fx3sqsaEaqklTWasLzlNJzMB8GA1UdIwQYMBaAFBQusxe3WFbLrlAJQOYf
|
||||||
|
r52LFMLGMFUGCCsGAQUFBwEBBEkwRzAhBggrBgEFBQcwAYYVaHR0cDovL3IzLm8u
|
||||||
|
bGVuY3Iub3JnMCIGCCsGAQUFBzAChhZodHRwOi8vcjMuaS5sZW5jci5vcmcvMDgG
|
||||||
|
A1UdEQQxMC+CFWhvbWVsYWIubWFyaW5vZGV2LmNvbYIWbWFyaW5vLW5hcy5zeW5v
|
||||||
|
bG9neS5tZTATBgNVHSAEDDAKMAgGBmeBDAECATCCAQMGCisGAQQB1nkCBAIEgfQE
|
||||||
|
gfEA7wB2AEiw42vapkc0D+VqAvqdMOscUgHLVt0sgdm7v6s52IRzAAABjGqqUTkA
|
||||||
|
AAQDAEcwRQIhAJncD2v9CgQii1KCLJhILJ96Jy7mE3a1ptaZ8sip8k3xAiBXw7ML
|
||||||
|
wbp/ikIzl0xYTeJsjU7lp7/VI26K+luw++dsMgB1AO7N0GTV2xrOxVy3nbTNE6Iy
|
||||||
|
h0Z8vOzew1FIWUZxH7WbAAABjGqqUTsAAAQDAEYwRAIgSXZW95Cafz5olbebYbSH
|
||||||
|
xlvPXhmJaspB7XzEsQP2i6kCIHa1QcGg9vyXJ6apl7WSPIz4DLJb6/ZeaHkPqAC5
|
||||||
|
NjKPMA0GCSqGSIb3DQEBCwUAA4IBAQBSKsqvA8v8h1WmTjudd8cRWc3RdU6lgq/E
|
||||||
|
pTXX6XWYFpU+D7jprp/NeW8RmVToQRUi6A3Bv9KnrsHG5HpwJ37SLh6Gv8s2t1A/
|
||||||
|
8FyNyndjuBKxFSaoJKkqlKUA657dXh67if5WLZYZYQdArRw3Q+fQOfSit8+RomTY
|
||||||
|
xmNVnRVO5+JRwxwbk/WT8tZHOb3Cd7Ozo7d2vpwH/KqY4RM7ajV8shzulMlAtqfT
|
||||||
|
ahi4ph8eUm43nCJPsVa4ddQLaV4z8EXoQ/SAsjrMkbAyg4G3uKoCqPUX4lnvqAAW
|
||||||
|
7kxmH8lJpkh76sz7gT1j/vzk9Fbslk3+8oa8PUO9PYQWfYwzWIs2
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFFjCCAv6gAwIBAgIRAJErCErPDBinU/bWLiWnX1owDQYJKoZIhvcNAQELBQAw
|
||||||
|
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||||
|
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMjAwOTA0MDAwMDAw
|
||||||
|
WhcNMjUwOTE1MTYwMDAwWjAyMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg
|
||||||
|
RW5jcnlwdDELMAkGA1UEAxMCUjMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
|
||||||
|
AoIBAQC7AhUozPaglNMPEuyNVZLD+ILxmaZ6QoinXSaqtSu5xUyxr45r+XXIo9cP
|
||||||
|
R5QUVTVXjJ6oojkZ9YI8QqlObvU7wy7bjcCwXPNZOOftz2nwWgsbvsCUJCWH+jdx
|
||||||
|
sxPnHKzhm+/b5DtFUkWWqcFTzjTIUu61ru2P3mBw4qVUq7ZtDpelQDRrK9O8Zutm
|
||||||
|
NHz6a4uPVymZ+DAXXbpyb/uBxa3Shlg9F8fnCbvxK/eG3MHacV3URuPMrSXBiLxg
|
||||||
|
Z3Vms/EY96Jc5lP/Ooi2R6X/ExjqmAl3P51T+c8B5fWmcBcUr2Ok/5mzk53cU6cG
|
||||||
|
/kiFHaFpriV1uxPMUgP17VGhi9sVAgMBAAGjggEIMIIBBDAOBgNVHQ8BAf8EBAMC
|
||||||
|
AYYwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMBMBIGA1UdEwEB/wQIMAYB
|
||||||
|
Af8CAQAwHQYDVR0OBBYEFBQusxe3WFbLrlAJQOYfr52LFMLGMB8GA1UdIwQYMBaA
|
||||||
|
FHm0WeZ7tuXkAXOACIjIGlj26ZtuMDIGCCsGAQUFBwEBBCYwJDAiBggrBgEFBQcw
|
||||||
|
AoYWaHR0cDovL3gxLmkubGVuY3Iub3JnLzAnBgNVHR8EIDAeMBygGqAYhhZodHRw
|
||||||
|
Oi8veDEuYy5sZW5jci5vcmcvMCIGA1UdIAQbMBkwCAYGZ4EMAQIBMA0GCysGAQQB
|
||||||
|
gt8TAQEBMA0GCSqGSIb3DQEBCwUAA4ICAQCFyk5HPqP3hUSFvNVneLKYY611TR6W
|
||||||
|
PTNlclQtgaDqw+34IL9fzLdwALduO/ZelN7kIJ+m74uyA+eitRY8kc607TkC53wl
|
||||||
|
ikfmZW4/RvTZ8M6UK+5UzhK8jCdLuMGYL6KvzXGRSgi3yLgjewQtCPkIVz6D2QQz
|
||||||
|
CkcheAmCJ8MqyJu5zlzyZMjAvnnAT45tRAxekrsu94sQ4egdRCnbWSDtY7kh+BIm
|
||||||
|
lJNXoB1lBMEKIq4QDUOXoRgffuDghje1WrG9ML+Hbisq/yFOGwXD9RiX8F6sw6W4
|
||||||
|
avAuvDszue5L3sz85K+EC4Y/wFVDNvZo4TYXao6Z0f+lQKc0t8DQYzk1OXVu8rp2
|
||||||
|
yJMC6alLbBfODALZvYH7n7do1AZls4I9d1P4jnkDrQoxB3UqQ9hVl3LEKQ73xF1O
|
||||||
|
yK5GhDDX8oVfGKF5u+decIsH4YaTw7mP3GFxJSqv3+0lUFJoi5Lc5da149p90Ids
|
||||||
|
hCExroL1+7mryIkXPeFM5TgO9r0rvZaBFOvV2z0gp35Z0+L4WPlbuEjN/lxPFin+
|
||||||
|
HlUjr8gRsI3qfJOQFy/9rKIJR0Y/8Omwt/8oTWgy1mdeHmmjk7j1nYsvC9JSQ6Zv
|
||||||
|
MldlTTKB3zhThV1+XWYp6rjd5JW1zbVWEkLNxE7GJThEUG3szgBVGP7pSWTUTsqX
|
||||||
|
nLRbwHOoq7hHwg==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFYDCCBEigAwIBAgIQQAF3ITfU6UK47naqPGQKtzANBgkqhkiG9w0BAQsFADA/
|
||||||
|
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||||
|
DkRTVCBSb290IENBIFgzMB4XDTIxMDEyMDE5MTQwM1oXDTI0MDkzMDE4MTQwM1ow
|
||||||
|
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
||||||
|
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwggIiMA0GCSqGSIb3DQEB
|
||||||
|
AQUAA4ICDwAwggIKAoICAQCt6CRz9BQ385ueK1coHIe+3LffOJCMbjzmV6B493XC
|
||||||
|
ov71am72AE8o295ohmxEk7axY/0UEmu/H9LqMZshftEzPLpI9d1537O4/xLxIZpL
|
||||||
|
wYqGcWlKZmZsj348cL+tKSIG8+TA5oCu4kuPt5l+lAOf00eXfJlII1PoOK5PCm+D
|
||||||
|
LtFJV4yAdLbaL9A4jXsDcCEbdfIwPPqPrt3aY6vrFk/CjhFLfs8L6P+1dy70sntK
|
||||||
|
4EwSJQxwjQMpoOFTJOwT2e4ZvxCzSow/iaNhUd6shweU9GNx7C7ib1uYgeGJXDR5
|
||||||
|
bHbvO5BieebbpJovJsXQEOEO3tkQjhb7t/eo98flAgeYjzYIlefiN5YNNnWe+w5y
|
||||||
|
sR2bvAP5SQXYgd0FtCrWQemsAXaVCg/Y39W9Eh81LygXbNKYwagJZHduRze6zqxZ
|
||||||
|
Xmidf3LWicUGQSk+WT7dJvUkyRGnWqNMQB9GoZm1pzpRboY7nn1ypxIFeFntPlF4
|
||||||
|
FQsDj43QLwWyPntKHEtzBRL8xurgUBN8Q5N0s8p0544fAQjQMNRbcTa0B7rBMDBc
|
||||||
|
SLeCO5imfWCKoqMpgsy6vYMEG6KDA0Gh1gXxG8K28Kh8hjtGqEgqiNx2mna/H2ql
|
||||||
|
PRmP6zjzZN7IKw0KKP/32+IVQtQi0Cdd4Xn+GOdwiK1O5tmLOsbdJ1Fu/7xk9TND
|
||||||
|
TwIDAQABo4IBRjCCAUIwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
|
||||||
|
SwYIKwYBBQUHAQEEPzA9MDsGCCsGAQUFBzAChi9odHRwOi8vYXBwcy5pZGVudHJ1
|
||||||
|
c3QuY29tL3Jvb3RzL2RzdHJvb3RjYXgzLnA3YzAfBgNVHSMEGDAWgBTEp7Gkeyxx
|
||||||
|
+tvhS5B1/8QVYIWJEDBUBgNVHSAETTBLMAgGBmeBDAECATA/BgsrBgEEAYLfEwEB
|
||||||
|
ATAwMC4GCCsGAQUFBwIBFiJodHRwOi8vY3BzLnJvb3QteDEubGV0c2VuY3J5cHQu
|
||||||
|
b3JnMDwGA1UdHwQ1MDMwMaAvoC2GK2h0dHA6Ly9jcmwuaWRlbnRydXN0LmNvbS9E
|
||||||
|
U1RST09UQ0FYM0NSTC5jcmwwHQYDVR0OBBYEFHm0WeZ7tuXkAXOACIjIGlj26Ztu
|
||||||
|
MA0GCSqGSIb3DQEBCwUAA4IBAQAKcwBslm7/DlLQrt2M51oGrS+o44+/yQoDFVDC
|
||||||
|
5WxCu2+b9LRPwkSICHXM6webFGJueN7sJ7o5XPWioW5WlHAQU7G75K/QosMrAdSW
|
||||||
|
9MUgNTP52GE24HGNtLi1qoJFlcDyqSMo59ahy2cI2qBDLKobkx/J3vWraV0T9VuG
|
||||||
|
WCLKTVXkcGdtwlfFRjlBz4pYg1htmf5X6DYO8A4jqv2Il9DjXA6USbW1FzXSLr9O
|
||||||
|
he8Y4IWS6wY7bCkjCWDcRQJMEhg76fsO3txE+FiYruq9RUWhiF1myv4Q6W+CyBFC
|
||||||
|
Dfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5
|
||||||
|
-----END CERTIFICATE-----
|
||||||
5
fbla-api/certificates/privkey.pem
Normal file
5
fbla-api/certificates/privkey.pem
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgBRfv5A/Ky/0a239v
|
||||||
|
+dD1tqdxLpNTW4S1Xnu7FhizFyWhRANCAAREezQ1+xQDRX+9j6sJeYWqHM0HIYjo
|
||||||
|
TBjcjGuX6E9GmBtg3jEHhIaZfte7wcxMLinsLo3oEDVmXTR1WxsanVJl
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
@ -3,14 +3,13 @@ version: '3'
|
|||||||
services:
|
services:
|
||||||
fbla_api:
|
fbla_api:
|
||||||
image: fbla-api
|
image: fbla-api
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
volumes:
|
volumes:
|
||||||
- /var/jenkins_home/logos:/root/FBLA24/fbla-api/logos
|
- /var/jenkins_home/logos:/root/FBLA24/fbla-api/logos
|
||||||
environment:
|
environment:
|
||||||
- JOBLINK_POSTGRES_USERNAME
|
- POSTGRES_USERNAME
|
||||||
- JOBLINK_POSTGRES_PASSWORD
|
- POSTGRES_PASSWORD
|
||||||
- JOBLINK_SECRET_KEY
|
- SECRET_KEY
|
||||||
- JOBLINK_POSTGRES_ADDRESS
|
- POSTGRES_ADDRESS
|
||||||
- JOBLINK_POSTGRES_PORT
|
- POSTGRES_PORT
|
||||||
@ -1,17 +1,14 @@
|
|||||||
import 'dart:io';
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:argon2/argon2.dart';
|
import 'package:argon2/argon2.dart';
|
||||||
|
import 'dart:io';
|
||||||
import 'package:postgres/postgres.dart';
|
import 'package:postgres/postgres.dart';
|
||||||
|
|
||||||
// Set these to the desired username and password of your user
|
|
||||||
String username = 'admin';
|
String username = 'admin';
|
||||||
String password = 'adminPassword';
|
String password = 'password';
|
||||||
|
|
||||||
var r = Random.secure();
|
var r = Random.secure();
|
||||||
String randomSalt =
|
String randomSalt = String.fromCharCodes(List.generate(32, (index) => r.nextInt(33) + 89));
|
||||||
String.fromCharCodes(List.generate(32, (index) => r.nextInt(33) + 89));
|
|
||||||
final salt = randomSalt.toBytesLatin1();
|
final salt = randomSalt.toBytesLatin1();
|
||||||
|
|
||||||
var parameters = Argon2Parameters(
|
var parameters = Argon2Parameters(
|
||||||
@ -23,11 +20,11 @@ var parameters = Argon2Parameters(
|
|||||||
);
|
);
|
||||||
|
|
||||||
final postgres = PostgreSQLConnection(
|
final postgres = PostgreSQLConnection(
|
||||||
Platform.environment['JOBLINK_POSTGRES_ADDRESS']!,
|
Platform.environment['POSTGRES_ADDRESS']!,
|
||||||
int.parse(Platform.environment['JOBLINK_POSTGRES_PORT']!),
|
int.parse(Platform.environment['POSTGRES_PORT']!),
|
||||||
'fbla',
|
'fbla',
|
||||||
username: Platform.environment['JOBLINK_POSTGRES_USERNAME'],
|
username: Platform.environment['POSTGRES_USERNAME'],
|
||||||
password: Platform.environment['JOBLINK_POSTGRES_PASSWORD'],
|
password: Platform.environment['POSTGRES_PASSWORD'],
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
@ -40,8 +37,10 @@ Future<void> main() async {
|
|||||||
argon2.generateBytes(passwordBytes, result);
|
argon2.generateBytes(passwordBytes, result);
|
||||||
var resultHex = result.toHexString();
|
var resultHex = result.toHexString();
|
||||||
|
|
||||||
postgres.query('''
|
postgres.query(
|
||||||
|
'''
|
||||||
INSERT INTO public.users (username, password_hash, salt)
|
INSERT INTO public.users (username, password_hash, salt)
|
||||||
VALUES ('$username', '$resultHex', '$randomSalt')
|
VALUES ('$username', '$resultHex', '$randomSalt')
|
||||||
''');
|
'''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,65 +2,51 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:argon2/argon2.dart';
|
|
||||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'package:postgres/postgres.dart';
|
import 'package:postgres/postgres.dart';
|
||||||
import 'package:shelf/shelf.dart';
|
import 'package:shelf/shelf.dart';
|
||||||
import 'package:shelf/shelf_io.dart' as io;
|
import 'package:shelf/shelf_io.dart' as io;
|
||||||
import 'package:shelf_router/shelf_router.dart';
|
import 'package:shelf_router/shelf_router.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:argon2/argon2.dart';
|
||||||
|
|
||||||
SecretKey secretKey = SecretKey(Platform.environment['JOBLINK_SECRET_KEY']!);
|
|
||||||
|
SecretKey secretKey = SecretKey(Platform.environment['SECRET_KEY']!);
|
||||||
|
|
||||||
enum BusinessType {
|
enum BusinessType {
|
||||||
food,
|
food,
|
||||||
shop,
|
shop,
|
||||||
outdoors,
|
outdoors,
|
||||||
manufacturing,
|
manufacturing,
|
||||||
entertainment,
|
|
||||||
other,
|
other,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum JobType {
|
|
||||||
retail,
|
|
||||||
customerService,
|
|
||||||
foodService,
|
|
||||||
finance,
|
|
||||||
healthcare,
|
|
||||||
education,
|
|
||||||
maintenance,
|
|
||||||
manufacturing,
|
|
||||||
other,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum OfferType { job, internship, apprenticeship }
|
|
||||||
|
|
||||||
class Business {
|
class Business {
|
||||||
int id;
|
int id;
|
||||||
String name;
|
String name;
|
||||||
String description;
|
String description;
|
||||||
BusinessType? type;
|
BusinessType type;
|
||||||
String? website;
|
String website;
|
||||||
String? contactName;
|
String contactName;
|
||||||
String? contactEmail;
|
String contactEmail;
|
||||||
String? contactPhone;
|
String contactPhone;
|
||||||
String? notes;
|
String notes;
|
||||||
String? locationName;
|
String locationName;
|
||||||
String? locationAddress;
|
String locationAddress;
|
||||||
|
|
||||||
Business(
|
Business({
|
||||||
{required this.id,
|
required this.id,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.description,
|
required this.description,
|
||||||
this.type,
|
required this.type,
|
||||||
this.website,
|
required this.website,
|
||||||
this.contactName,
|
required this.contactName,
|
||||||
this.contactEmail,
|
required this.contactEmail,
|
||||||
this.contactPhone,
|
required this.contactPhone,
|
||||||
this.notes,
|
required this.notes,
|
||||||
this.locationName,
|
required this.locationName,
|
||||||
this.locationAddress});
|
required this.locationAddress,
|
||||||
|
});
|
||||||
|
|
||||||
factory Business.fromJson(Map<String, dynamic> json) {
|
factory Business.fromJson(Map<String, dynamic> json) {
|
||||||
bool typeValid = true;
|
bool typeValid = true;
|
||||||
@ -69,15 +55,14 @@ class Business {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
typeValid = false;
|
typeValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Business(
|
return Business(
|
||||||
id: json['id'],
|
id: json['id'],
|
||||||
name: json['name'],
|
name: json['name'],
|
||||||
description: json['description'],
|
description: json['description'],
|
||||||
website: json['website'],
|
|
||||||
type: typeValid
|
type: typeValid
|
||||||
? BusinessType.values.byName(json['type'])
|
? BusinessType.values.byName(json['type'])
|
||||||
: BusinessType.other,
|
: BusinessType.other,
|
||||||
|
website: json['website'],
|
||||||
contactName: json['contactName'],
|
contactName: json['contactName'],
|
||||||
contactEmail: json['contactEmail'],
|
contactEmail: json['contactEmail'],
|
||||||
contactPhone: json['contactPhone'],
|
contactPhone: json['contactPhone'],
|
||||||
@ -88,48 +73,9 @@ class Business {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JobListing {
|
|
||||||
int? id;
|
|
||||||
int? businessId;
|
|
||||||
String name;
|
|
||||||
String description;
|
|
||||||
JobType type;
|
|
||||||
String? wage;
|
|
||||||
String? link;
|
|
||||||
OfferType offerType;
|
|
||||||
|
|
||||||
JobListing(
|
|
||||||
{this.id,
|
|
||||||
this.businessId,
|
|
||||||
required this.name,
|
|
||||||
required this.description,
|
|
||||||
required this.type,
|
|
||||||
this.wage,
|
|
||||||
this.link,
|
|
||||||
required this.offerType});
|
|
||||||
|
|
||||||
factory JobListing.fromJson(Map<String, dynamic> json) {
|
|
||||||
bool typeValid = true;
|
|
||||||
try {
|
|
||||||
JobType.values.byName(json['type']);
|
|
||||||
} catch (e) {
|
|
||||||
typeValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JobListing(
|
|
||||||
id: json['id'],
|
|
||||||
businessId: json['businessId'],
|
|
||||||
name: json['name'],
|
|
||||||
description: json['description'],
|
|
||||||
type: typeValid ? JobType.values.byName(json['type']) : JobType.other,
|
|
||||||
wage: json['wage'],
|
|
||||||
link: json['link'],
|
|
||||||
offerType: OfferType.values.byName(json['offerType']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> fetchBusinessData() async {
|
Future<String> fetchBusinessData() async {
|
||||||
final result = await postgres.query('''
|
final result = await postgres.query(
|
||||||
|
'''
|
||||||
SELECT json_agg(
|
SELECT json_agg(
|
||||||
json_build_object(
|
json_build_object(
|
||||||
'id', id,
|
'id', id,
|
||||||
@ -145,9 +91,12 @@ Future<String> fetchBusinessData() async {
|
|||||||
'locationAddress', "locationAddress"
|
'locationAddress', "locationAddress"
|
||||||
)
|
)
|
||||||
) FROM businesses
|
) FROM businesses
|
||||||
''');
|
'''
|
||||||
|
);
|
||||||
|
|
||||||
var encoded = json.encode(result[0][0]);
|
var encoded = json.encode(result);
|
||||||
|
var decoded = json.decode(encoded);
|
||||||
|
encoded = json.encode(decoded[0][0]);
|
||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,28 +104,22 @@ Future<String> fetchBusinessData() async {
|
|||||||
String _hostname = 'localhost';
|
String _hostname = 'localhost';
|
||||||
const _port = 8000;
|
const _port = 8000;
|
||||||
|
|
||||||
|
|
||||||
final postgres = PostgreSQLConnection(
|
final postgres = PostgreSQLConnection(
|
||||||
Platform.environment['JOBLINK_POSTGRES_ADDRESS']!,
|
Platform.environment['POSTGRES_ADDRESS']!,
|
||||||
int.parse(Platform.environment['JOBLINK_POSTGRES_PORT']!),
|
int.parse(Platform.environment['POSTGRES_PORT']!),
|
||||||
'fbla',
|
'fbla',
|
||||||
username: Platform.environment['JOBLINK_POSTGRES_USERNAME'],
|
username: Platform.environment['POSTGRES_USERNAME'],
|
||||||
password: Platform.environment['JOBLINK_POSTGRES_PASSWORD'],
|
password: Platform.environment['POSTGRES_PASSWORD'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
await postgres.open();
|
await postgres.open();
|
||||||
|
|
||||||
final app = Router();
|
final app = Router();
|
||||||
|
|
||||||
// CORS preflight acceptor
|
|
||||||
app.options('/<ignored|.*>', (Request request) {
|
|
||||||
return Response.ok(null, headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
|
|
||||||
'Access-Control-Allow-Headers': '*',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// routes
|
// routes
|
||||||
app.get('/fbla-api/hello', (Request request) async {
|
app.get('/fbla-api/hello', (Request request) async {
|
||||||
print('Hello received');
|
print('Hello received');
|
||||||
@ -186,254 +129,20 @@ void main() async {
|
|||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/businessdata/overview/jobs', (Request request) async {
|
|
||||||
print('business overview request received');
|
|
||||||
|
|
||||||
var typeFilters = request.url.queryParameters['typeFilters']?.split(',') ??
|
|
||||||
JobType.values.asNameMap().keys;
|
|
||||||
var offerFilters =
|
|
||||||
request.url.queryParameters['offerFilters']?.split(',') ??
|
|
||||||
OfferType.values.asNameMap().keys;
|
|
||||||
|
|
||||||
var postgresResult = (await postgres.query('''
|
|
||||||
SELECT jsonb_agg(
|
|
||||||
jsonb_build_object(
|
|
||||||
'id', b.id,
|
|
||||||
'name', b.name,
|
|
||||||
'contactName', b."contactName",
|
|
||||||
'contactEmail', b."contactEmail",
|
|
||||||
'contactPhone', b."contactPhone",
|
|
||||||
'locationName', b."locationName",
|
|
||||||
'locationAddress', b."locationAddress",
|
|
||||||
'listings', b.listings
|
|
||||||
)
|
|
||||||
) AS result
|
|
||||||
FROM (
|
|
||||||
SELECT
|
|
||||||
businesses.id,
|
|
||||||
businesses.name,
|
|
||||||
businesses."contactName",
|
|
||||||
businesses."contactEmail",
|
|
||||||
businesses."contactPhone",
|
|
||||||
businesses."locationName",
|
|
||||||
businesses."locationAddress",
|
|
||||||
jsonb_agg(
|
|
||||||
jsonb_build_object(
|
|
||||||
'id', listings.id,
|
|
||||||
'name', listings.name,
|
|
||||||
'description', listings.description,
|
|
||||||
'type', listings.type,
|
|
||||||
'wage', listings.wage,
|
|
||||||
'link', listings.link,
|
|
||||||
'offerType', listings."offerType"
|
|
||||||
)
|
|
||||||
) AS listings
|
|
||||||
FROM businesses
|
|
||||||
JOIN listings ON businesses.id = listings."businessId"
|
|
||||||
AND listings.type IN (${typeFilters.map((element) => "'$element'").join(',')})
|
|
||||||
AND listings."offerType" IN (${offerFilters.map((element) => "'$element'").join(',')})
|
|
||||||
GROUP BY businesses.id, businesses.name, businesses."contactName", businesses."contactEmail",
|
|
||||||
businesses."contactPhone", businesses."locationName", businesses."locationAddress"
|
|
||||||
) b
|
|
||||||
WHERE b.listings IS NOT NULL;
|
|
||||||
'''));
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
json.encode(postgresResult[0][0]),
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.get('/fbla-api/businessdata/overview/types', (Request request) async {
|
|
||||||
print('business overview request received');
|
|
||||||
|
|
||||||
var filters = request.url.queryParameters['filters']?.split(',') ??
|
|
||||||
BusinessType.values.asNameMap().keys;
|
|
||||||
|
|
||||||
// List<Map<String, List<Map<String, dynamic>>>> this is the real type lol
|
|
||||||
Map<String, dynamic> output = {};
|
|
||||||
|
|
||||||
for (int i = 0; i < filters.length; i++) {
|
|
||||||
var postgresResult = (await postgres.query('''
|
|
||||||
SELECT json_agg(
|
|
||||||
json_build_object(
|
|
||||||
'id', id,
|
|
||||||
'name', name,
|
|
||||||
'description', description,
|
|
||||||
'website', website,
|
|
||||||
'contactName', "contactName",
|
|
||||||
'contactEmail', "contactEmail",
|
|
||||||
'contactPhone', "contactPhone",
|
|
||||||
'locationName', "locationName",
|
|
||||||
'locationAddress', "locationAddress"
|
|
||||||
)
|
|
||||||
) FROM public.businesses WHERE type='${filters.elementAt(i)}'
|
|
||||||
'''))[0][0];
|
|
||||||
|
|
||||||
if (postgresResult != null) {
|
|
||||||
output.addAll({filters.elementAt(i): postgresResult});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
json.encode(output),
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.get('/fbla-api/businessdata/businessnames', (Request request) async {
|
|
||||||
print('business names request received');
|
|
||||||
|
|
||||||
var postgresResult = (await postgres.query('''
|
|
||||||
SELECT json_agg(
|
|
||||||
json_build_object(
|
|
||||||
'id', id,
|
|
||||||
'name', name
|
|
||||||
)
|
|
||||||
) FROM public.businesses
|
|
||||||
'''))[0][0];
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
json.encode(postgresResult),
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.get('/fbla-api/businessdata/business/<business>',
|
|
||||||
(Request request, String business) async {
|
|
||||||
print('idividual business data request received');
|
|
||||||
|
|
||||||
var result = (await postgres.query('''
|
|
||||||
SELECT
|
|
||||||
json_build_object(
|
|
||||||
'id', b.id,
|
|
||||||
'name', b.name,
|
|
||||||
'description', b.description,
|
|
||||||
'type', b.type,
|
|
||||||
'website', b.website,
|
|
||||||
'contactName', b."contactName",
|
|
||||||
'contactEmail', b."contactEmail",
|
|
||||||
'contactPhone', b."contactPhone",
|
|
||||||
'notes', b.notes,
|
|
||||||
'locationName', b."locationName",
|
|
||||||
'locationAddress', b."locationAddress",
|
|
||||||
'listings',
|
|
||||||
CASE
|
|
||||||
WHEN COUNT(l.id) = 0 THEN 'null'
|
|
||||||
ELSE json_agg(
|
|
||||||
json_build_object(
|
|
||||||
'id', l.id,
|
|
||||||
'businessId', l."businessId",
|
|
||||||
'name', l.name,
|
|
||||||
'description', l.description,
|
|
||||||
'type', l.type,
|
|
||||||
'offerType', l."offerType",
|
|
||||||
'wage', l.wage,
|
|
||||||
'link', l.link
|
|
||||||
)
|
|
||||||
)
|
|
||||||
END
|
|
||||||
)
|
|
||||||
FROM businesses b
|
|
||||||
LEFT JOIN listings l ON b.id = l."businessId"
|
|
||||||
WHERE b.id = $business
|
|
||||||
GROUP BY b.id;
|
|
||||||
'''))[0][0];
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
json.encode(result),
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.get('/fbla-api/businessdata/businesses', (Request request) async {
|
|
||||||
print('list of business data request received');
|
|
||||||
|
|
||||||
if (request.url.queryParameters['businesses'] == null) {
|
|
||||||
return Response.badRequest(
|
|
||||||
body: 'query \'businesses\' required',
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
var filters = request.url.queryParameters['businesses']!.split(',');
|
|
||||||
|
|
||||||
var result = (await postgres.query('''
|
|
||||||
SELECT
|
|
||||||
json_build_object(
|
|
||||||
'id', b.id,
|
|
||||||
'name', b.name,
|
|
||||||
'description', b.description,
|
|
||||||
'website', b.website,
|
|
||||||
'type', b.type,
|
|
||||||
'contactName', b."contactName",
|
|
||||||
'contactEmail', b."contactEmail",
|
|
||||||
'contactPhone', b."contactPhone",
|
|
||||||
'notes', b.notes,
|
|
||||||
'locationName', b."locationName",
|
|
||||||
'locationAddress', b."locationAddress"
|
|
||||||
)
|
|
||||||
FROM businesses b
|
|
||||||
LEFT JOIN listings l ON b.id = l."businessId"
|
|
||||||
WHERE b.id IN (${filters.join(',')})
|
|
||||||
GROUP BY b.id;
|
|
||||||
'''));
|
|
||||||
|
|
||||||
var output = result.map((element) => element[0]).toList();
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
json.encode(output),
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.get('/fbla-api/businessdata', (Request request) async {
|
app.get('/fbla-api/businessdata', (Request request) async {
|
||||||
print('business data request received');
|
print('business data request received');
|
||||||
final result = await postgres.query('''
|
final output = await fetchBusinessData();
|
||||||
SELECT json_agg(
|
|
||||||
json_build_object(
|
|
||||||
'id', id,
|
|
||||||
'name', name,
|
|
||||||
'description', description,
|
|
||||||
'type', type,
|
|
||||||
'website', website,
|
|
||||||
'contactName', "contactName",
|
|
||||||
'contactEmail', "contactEmail",
|
|
||||||
'contactPhone', "contactPhone",
|
|
||||||
'notes', notes,
|
|
||||||
'locationName', "locationName",
|
|
||||||
'locationAddress', "locationAddress"
|
|
||||||
)
|
|
||||||
) FROM businesses
|
|
||||||
''');
|
|
||||||
|
|
||||||
var encoded = json.encode(result[0][0]);
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
encoded,
|
output.toString(),
|
||||||
headers: {
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/logos/<logo>', (Request request, String logoId) {
|
app.get('/fbla-api/logos/<logo>', (Request request, String logoId) {
|
||||||
print('business logo request received');
|
print('business logo request received');
|
||||||
|
|
||||||
var logo = File('logos/$logoId.png');
|
var logo = File('logos/$logoId.png');
|
||||||
try {
|
|
||||||
List<int> content = logo.readAsBytesSync();
|
List<int> content = logo.readAsBytesSync();
|
||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
content,
|
content,
|
||||||
headers: {
|
headers: {
|
||||||
@ -441,16 +150,6 @@ void main() async {
|
|||||||
'Content-Type': 'image/png'
|
'Content-Type': 'image/png'
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
print('Error reading logo!');
|
|
||||||
return Response.notFound(
|
|
||||||
'logo not found',
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'image/png'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/createbusiness', (Request request) async {
|
app.post('/fbla-api/createbusiness', (Request request) async {
|
||||||
print('create business request received');
|
print('create business request received');
|
||||||
@ -462,13 +161,15 @@ void main() async {
|
|||||||
var json = jsonDecode(payload);
|
var json = jsonDecode(payload);
|
||||||
Business business = Business.fromJson(json);
|
Business business = Business.fromJson(json);
|
||||||
|
|
||||||
await postgres.query('''
|
await postgres.query(
|
||||||
INSERT INTO businesses (name, description, website, type, "contactName", "contactPhone", "contactEmail", notes, "locationName", "locationAddress")
|
|
||||||
VALUES ('${business.name.replaceAll("'", "''")}', '${business.description.replaceAll("'", "''")}', '${business.website ?? 'NULL'}', '${business.type?.name}', '${business.contactName?.replaceAll("'", "''") ?? 'NULL'}', '${business.contactPhone ?? 'NULL'}', '${business.contactEmail ?? 'NULL'}', '${business.notes?.replaceAll("'", "''") ?? 'NULL'}', '${business.locationName?.replaceAll("'", "''") ?? 'NULL'}', '${business.locationAddress?.replaceAll("'", "''") ?? 'NULL'}')
|
|
||||||
'''
|
'''
|
||||||
.replaceAll("'null'", 'NULL'));
|
INSERT INTO businesses (name, description, type, website, "contactName", "contactPhone", "contactEmail", notes, "locationName", "locationAddress")
|
||||||
|
VALUES ('${business.name.replaceAll("'", "''")}', '${business.description.replaceAll("'", "''")}', '${business.type.name}', '${business.website}', '${business.contactName.replaceAll("'", "''")}', '${business.contactPhone}', '${business.contactEmail}', '${business.notes.replaceAll("'", "''")}', '${business.locationName.replaceAll("'", "''")}', '${business.locationAddress.replaceAll("'", "''")}')
|
||||||
|
'''
|
||||||
|
);
|
||||||
|
|
||||||
final dbBusiness = await postgres.query('''SELECT * FROM public.businesses
|
final dbBusiness = await postgres.query(
|
||||||
|
'''SELECT * FROM public.businesses
|
||||||
ORDER BY id DESC LIMIT 1''');
|
ORDER BY id DESC LIMIT 1''');
|
||||||
var id = dbBusiness[0][0];
|
var id = dbBusiness[0][0];
|
||||||
var logoResponse = await http.get(
|
var logoResponse = await http.get(
|
||||||
@ -493,44 +194,10 @@ void main() async {
|
|||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/createlisting', (Request request) async {
|
|
||||||
print('create business request received');
|
|
||||||
|
|
||||||
final payload = await request.readAsString();
|
|
||||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
|
||||||
try {
|
|
||||||
JWT.verify(auth!, secretKey);
|
|
||||||
var json = jsonDecode(payload);
|
|
||||||
JobListing listing = JobListing.fromJson(json);
|
|
||||||
|
|
||||||
await postgres.query('''
|
|
||||||
INSERT INTO listings ("businessId", name, description, type, wage, link, "offerType")
|
|
||||||
VALUES ('${listing.businessId}', '${listing.name.replaceAll("'", "''")}', '${listing.description.replaceAll("'", "''")}', '${listing.type.name}', '${listing.wage ?? 'NULL'}', '${listing.link?.replaceAll("'", "''") ?? 'NULL'}', '${listing.offerType.name}')
|
|
||||||
'''
|
|
||||||
.replaceAll("'null'", 'NULL'));
|
|
||||||
|
|
||||||
final dbListing = await postgres.query('''SELECT id FROM public.listings
|
|
||||||
ORDER BY id DESC LIMIT 1''');
|
|
||||||
var id = dbListing[0][0];
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
id.toString(),
|
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
|
||||||
);
|
|
||||||
} on JWTExpiredException {
|
|
||||||
print('JWT Expired');
|
|
||||||
} on JWTException catch (e) {
|
|
||||||
print(e.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response.unauthorized(
|
|
||||||
'unauthorized',
|
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.post('/fbla-api/deletebusiness', (Request request) async {
|
app.post('/fbla-api/deletebusiness', (Request request) async {
|
||||||
print('delete business request received');
|
print('delete business request received');
|
||||||
|
|
||||||
|
|
||||||
final payload = await request.readAsString();
|
final payload = await request.readAsString();
|
||||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
||||||
try {
|
try {
|
||||||
@ -538,12 +205,18 @@ void main() async {
|
|||||||
var json = jsonDecode(payload);
|
var json = jsonDecode(payload);
|
||||||
var id = json['id'];
|
var id = json['id'];
|
||||||
|
|
||||||
await postgres.query('DELETE FROM public.businesses WHERE id=$id;');
|
await postgres.query(
|
||||||
|
'''
|
||||||
|
DELETE FROM public.businesses
|
||||||
|
WHERE id IN
|
||||||
|
($id);
|
||||||
|
'''
|
||||||
|
);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await File('logos/$id.png').delete();
|
await File('logos/$id.png').delete();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
print('Failure to delete logo! $e');
|
print(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
@ -561,33 +234,6 @@ void main() async {
|
|||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/deletelisting', (Request request) async {
|
|
||||||
print('delete listing request received');
|
|
||||||
|
|
||||||
final payload = await request.readAsString();
|
|
||||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
|
||||||
try {
|
|
||||||
JWT.verify(auth!, secretKey);
|
|
||||||
var json = jsonDecode(payload);
|
|
||||||
var id = json['id'];
|
|
||||||
|
|
||||||
await postgres.query('DELETE FROM public.listings WHERE id=$id;');
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
id.toString(),
|
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
|
||||||
);
|
|
||||||
} on JWTExpiredException {
|
|
||||||
print('JWT Expired');
|
|
||||||
} on JWTException catch (e) {
|
|
||||||
print(e.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response.unauthorized(
|
|
||||||
'unauthorized',
|
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.post('/fbla-api/editbusiness', (Request request) async {
|
app.post('/fbla-api/editbusiness', (Request request) async {
|
||||||
print('edit business request received');
|
print('edit business request received');
|
||||||
|
|
||||||
@ -599,12 +245,13 @@ void main() async {
|
|||||||
var json = jsonDecode(payload);
|
var json = jsonDecode(payload);
|
||||||
Business business = Business.fromJson(json);
|
Business business = Business.fromJson(json);
|
||||||
|
|
||||||
await postgres.query('''
|
await postgres.query(
|
||||||
|
'''
|
||||||
UPDATE businesses SET
|
UPDATE businesses SET
|
||||||
name = '${business.name.replaceAll("'", "''").replaceAll("\"", "\"\"")}'::text, description = '${business.description.replaceAll("'", "''").replaceAll("\"", "\"\"")}'::text, website = '${business.website!}'::text, "contactName" = '${business.contactName!.replaceAll("'", "''").replaceAll("\"", "\"\"")}'::text, "contactPhone" = '${business.contactPhone!}'::text, "contactEmail" = '${business.contactEmail!}'::text, notes = '${business.notes!.replaceAll("'", "''").replaceAll("\"", "\"\"")}'::text, "locationName" = '${business.locationName!.replaceAll("'", "''").replaceAll("\"", "\"\"")}'::text, "locationAddress" = '${business.locationAddress!.replaceAll("'", "''").replaceAll("\"", "\"\"")}'::text WHERE
|
name = '${business.name.replaceAll("'", "''")}'::text, description = '${business.description.replaceAll("'", "''")}'::text, website = '${business.website}'::text, type = '${business.type.name}'::text, "contactName" = '${business.contactName.replaceAll("'", "''")}'::text, "contactPhone" = '${business.contactPhone}'::text, "contactEmail" = '${business.contactEmail}'::text, notes = '${business.notes.replaceAll("'", "''")}'::text, "locationName" = '${business.locationName.replaceAll("'", "''")}'::text, "locationAddress" = '${business.locationAddress.replaceAll("'", "''")}'::text WHERE
|
||||||
id = ${business.id};
|
id = ${business.id};
|
||||||
'''
|
'''
|
||||||
.replaceAll("'null'", 'NULL'));
|
);
|
||||||
|
|
||||||
var logoResponse = await http.get(
|
var logoResponse = await http.get(
|
||||||
Uri.http('logo.clearbit.com', '/${business.website}'),
|
Uri.http('logo.clearbit.com', '/${business.website}'),
|
||||||
@ -613,13 +260,14 @@ void main() async {
|
|||||||
try {
|
try {
|
||||||
await File('logos/${business.id}.png').delete();
|
await File('logos/${business.id}.png').delete();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
print('Failure to delete logo! $e');
|
print(e);
|
||||||
}
|
}
|
||||||
if (logoResponse.headers.toString().contains('image/png')) {
|
if (logoResponse.headers.toString().contains('image/png')) {
|
||||||
await File('logos/${business.id}.png')
|
await File('logos/${business.id}.png').writeAsBytes(logoResponse.bodyBytes);
|
||||||
.writeAsBytes(logoResponse.bodyBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
business.id.toString(),
|
business.id.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
@ -635,39 +283,6 @@ void main() async {
|
|||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/editlisting', (Request request) async {
|
|
||||||
print('edit listing request received');
|
|
||||||
|
|
||||||
final payload = await request.readAsString();
|
|
||||||
var auth = request.headers['Authorization']?.replaceAll('Bearer ', '');
|
|
||||||
try {
|
|
||||||
JWT.verify(auth!, secretKey);
|
|
||||||
|
|
||||||
var json = jsonDecode(payload);
|
|
||||||
JobListing listing = JobListing.fromJson(json);
|
|
||||||
|
|
||||||
await postgres.query('''
|
|
||||||
UPDATE listings SET
|
|
||||||
"businessId" = ${listing.businessId}, name = '${listing.name.replaceAll("'", "''")}'::text, description = '${listing.description.replaceAll("'", "''")}'::text, type = '${listing.type.name}'::text, wage = '${listing.wage ?? 'NULL'}'::text, link = '${listing.link?.replaceAll("'", "''") ?? 'NULL'}'::text, "offerType"='${listing.offerType.name}'::text WHERE
|
|
||||||
id = ${listing.id};
|
|
||||||
'''
|
|
||||||
.replaceAll("'null'", 'NULL'));
|
|
||||||
|
|
||||||
return Response.ok(
|
|
||||||
listing.id.toString(),
|
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
|
||||||
);
|
|
||||||
} on JWTExpiredException {
|
|
||||||
print('JWT Expired');
|
|
||||||
} on JWTException catch (e) {
|
|
||||||
print(e.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response.unauthorized(
|
|
||||||
'unauthorized',
|
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
app.post('/fbla-api/signin', (Request request) async {
|
app.post('/fbla-api/signin', (Request request) async {
|
||||||
print('signin request received');
|
print('signin request received');
|
||||||
|
|
||||||
@ -676,8 +291,9 @@ void main() async {
|
|||||||
var username = json['username'];
|
var username = json['username'];
|
||||||
var password = json['password'];
|
var password = json['password'];
|
||||||
|
|
||||||
var saltDb = await postgres
|
var saltDb = await postgres.query(
|
||||||
.query('SELECT salt FROM users WHERE username=\'$username\'');
|
'SELECT salt FROM users WHERE username=\'$username\''
|
||||||
|
);
|
||||||
if (saltDb.isEmpty) {
|
if (saltDb.isEmpty) {
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'invalid username',
|
'invalid username',
|
||||||
@ -703,13 +319,17 @@ void main() async {
|
|||||||
argon2.generateBytes(passwordBytes, result);
|
argon2.generateBytes(passwordBytes, result);
|
||||||
var resultHex = result.toHexString();
|
var resultHex = result.toHexString();
|
||||||
|
|
||||||
var passwordHashDb = await postgres
|
var passwordHashDb = await postgres.query(
|
||||||
.query('SELECT password_hash FROM users WHERE username=\'$username\'');
|
'SELECT password_hash FROM users WHERE username=\'$username\''
|
||||||
|
);
|
||||||
var passwordHash = passwordHashDb[0][0].toString();
|
var passwordHash = passwordHashDb[0][0].toString();
|
||||||
|
|
||||||
if (passwordHash == resultHex) {
|
if (passwordHash == resultHex) {
|
||||||
|
|
||||||
final jwt = JWT(
|
final jwt = JWT(
|
||||||
{'username': username},
|
{
|
||||||
|
'username': username
|
||||||
|
},
|
||||||
);
|
);
|
||||||
final token = jwt.sign(secretKey);
|
final token = jwt.sign(secretKey);
|
||||||
try {
|
try {
|
||||||
@ -724,6 +344,7 @@ void main() async {
|
|||||||
token.toString(),
|
token.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'invalid password',
|
'invalid password',
|
||||||
@ -745,8 +366,7 @@ void main() async {
|
|||||||
var password = json['password'];
|
var password = json['password'];
|
||||||
|
|
||||||
var r = Random.secure();
|
var r = Random.secure();
|
||||||
String randomSalt = String.fromCharCodes(
|
String randomSalt = String.fromCharCodes(List.generate(32, (index) => r.nextInt(33) + 89));
|
||||||
List.generate(32, (index) => r.nextInt(33) + 89));
|
|
||||||
final salt = randomSalt.toBytesLatin1();
|
final salt = randomSalt.toBytesLatin1();
|
||||||
|
|
||||||
var parameters = Argon2Parameters(
|
var parameters = Argon2Parameters(
|
||||||
@ -764,15 +384,18 @@ void main() async {
|
|||||||
argon2.generateBytes(passwordBytes, result);
|
argon2.generateBytes(passwordBytes, result);
|
||||||
var resultHex = result.toHexString();
|
var resultHex = result.toHexString();
|
||||||
|
|
||||||
postgres.query('''
|
postgres.query(
|
||||||
|
'''
|
||||||
INSERT INTO public.users (username, password_hash, salt)
|
INSERT INTO public.users (username, password_hash, salt)
|
||||||
VALUES ('$username', '$resultHex', '$randomSalt')
|
VALUES ('$username', '$resultHex', '$randomSalt')
|
||||||
''');
|
'''
|
||||||
|
);
|
||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
username,
|
username,
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
);
|
);
|
||||||
|
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
} on JWTException catch (e) {
|
} on JWTException catch (e) {
|
||||||
@ -796,15 +419,18 @@ void main() async {
|
|||||||
var json = jsonDecode(payload);
|
var json = jsonDecode(payload);
|
||||||
var username = json['username'];
|
var username = json['username'];
|
||||||
|
|
||||||
postgres.query('''
|
postgres.query(
|
||||||
|
'''
|
||||||
DELETE FROM public.users
|
DELETE FROM public.users
|
||||||
WHERE username IN ('$username');
|
WHERE username IN ('$username');
|
||||||
''');
|
'''
|
||||||
|
);
|
||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
username,
|
username,
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: {'Access-Control-Allow-Origin': '*'},
|
||||||
);
|
);
|
||||||
|
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
} on JWTException catch (e) {
|
} on JWTException catch (e) {
|
||||||
@ -830,31 +456,6 @@ void main() async {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/clearbit/<website>',
|
|
||||||
(Request request, String website) async {
|
|
||||||
print('clearbit logo request received');
|
|
||||||
|
|
||||||
website = Uri.decodeComponent(website);
|
|
||||||
|
|
||||||
var response =
|
|
||||||
await http.get(Uri.parse('https://logo.clearbit.com/$website'));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return Response.ok(
|
|
||||||
response.bodyBytes,
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'image/png'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Response.notFound(
|
|
||||||
'logo not found',
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// get ip address for hosting
|
// get ip address for hosting
|
||||||
for (var interface in await NetworkInterface.list()) {
|
for (var interface in await NetworkInterface.list()) {
|
||||||
|
|||||||
@ -5,15 +5,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
sha256: "5aaf60d96c4cd00fe7f21594b5ad6a1b699c80a27420f8a837f4d68473ef09e3"
|
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "68.0.0"
|
version: "64.0.0"
|
||||||
_macros:
|
|
||||||
dependency: transitive
|
|
||||||
description: dart
|
|
||||||
source: sdk
|
|
||||||
version: "0.1.0"
|
|
||||||
adaptive_number:
|
adaptive_number:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -26,10 +21,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
sha256: "21f1d3720fd1c70316399d5e2bccaebb415c434592d778cce8acb967b8578808"
|
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.5.0"
|
version: "6.2.0"
|
||||||
argon2:
|
argon2:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -42,10 +37,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: args
|
name: args
|
||||||
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
|
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0"
|
version: "2.4.2"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -66,10 +61,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: buffer
|
name: buffer
|
||||||
sha256: "389da2ec2c16283c8787e0adaede82b1842102f8c8aae2f49003a766c5c6b3d1"
|
sha256: "8962c12174f53e2e848a6acd7ac7fd63d8a1a6a316c20c458a832d87eba5422a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.3"
|
version: "1.2.0"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -78,14 +73,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
clock:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: clock
|
|
||||||
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.1"
|
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -106,10 +93,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: coverage
|
name: coverage
|
||||||
sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
|
sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.6.3"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -122,10 +109,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: dart_jsonwebtoken
|
name: dart_jsonwebtoken
|
||||||
sha256: "346e9a21e4bf6e6a431e19ece00ebb2e3668e1e339cabdf6f46d18d88692a848"
|
sha256: "6703695f581fc54d0a7e5f281c5538735167605bb9e5abd208c8b330625a92b1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.14.0"
|
version: "2.12.1"
|
||||||
ed25519_edwards:
|
ed25519_edwards:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -154,10 +141,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: frontend_server_client
|
name: frontend_server_client
|
||||||
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
|
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.0"
|
version: "3.2.0"
|
||||||
glob:
|
glob:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -178,10 +165,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
|
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.1.0"
|
||||||
http_methods:
|
http_methods:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -218,10 +205,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: js
|
name: js
|
||||||
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
|
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.1"
|
version: "0.6.7"
|
||||||
lints:
|
lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@ -238,38 +225,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.0"
|
||||||
macros:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: macros
|
|
||||||
sha256: "12e8a9842b5a7390de7a781ec63d793527582398d16ea26c60fed58833c9ae79"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.0-main.0"
|
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.16+1"
|
version: "0.12.16"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
|
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.9.1"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: mime
|
name: mime
|
||||||
sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2"
|
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.0.4"
|
||||||
node_preamble:
|
node_preamble:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -290,10 +269,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.8.3"
|
||||||
pedantic:
|
pedantic:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -306,10 +285,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pointycastle
|
name: pointycastle
|
||||||
sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
|
sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.9.1"
|
version: "3.7.3"
|
||||||
pool:
|
pool:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -322,10 +301,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: postgres
|
name: postgres
|
||||||
sha256: f8e4f14734d096277f77ed5dddefcbc1ce18f8f7db5b7ff4b5dd6df2d9db2730
|
sha256: "98457afc06dd3f9d6892c178ea03ca9659e454107c9be90111e607691998d70d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.6.4"
|
version: "2.6.2"
|
||||||
pub_semver:
|
pub_semver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -386,10 +365,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shelf_web_socket
|
name: shelf_web_socket
|
||||||
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
|
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "1.0.4"
|
||||||
source_map_stack_trace:
|
source_map_stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -450,26 +429,26 @@ packages:
|
|||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: test
|
name: test
|
||||||
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
|
sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.25.7"
|
version: "1.24.6"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
|
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.2"
|
version: "0.6.1"
|
||||||
test_core:
|
test_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_core
|
name: test_core
|
||||||
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
|
sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.4"
|
version: "0.5.6"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -490,10 +469,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
sha256: "360c4271613beb44db559547d02f8b0dc044741d0eeb9aa6ccdb47e8ec54c63a"
|
sha256: "0fae432c85c4ea880b33b497d32824b97795b04cdaa74d270219572a1f50268d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "14.2.3"
|
version: "11.9.0"
|
||||||
watcher:
|
watcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -502,38 +481,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: web
|
|
||||||
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.5.1"
|
|
||||||
web_socket:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: web_socket
|
|
||||||
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.5"
|
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: web_socket_channel
|
name: web_socket_channel
|
||||||
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
|
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.0"
|
version: "2.4.0"
|
||||||
webkit_inspection_protocol:
|
webkit_inspection_protocol:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: webkit_inspection_protocol
|
name: webkit_inspection_protocol
|
||||||
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
|
sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.0"
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -543,4 +506,4 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.4.0-256.0.dev <4.0.0"
|
dart: ">=3.0.6 <4.0.0"
|
||||||
|
|||||||
@ -1,17 +1,18 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||||
import 'package:fbla_api/fbla_api.dart';
|
import 'package:fbla_api/fbla_api.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
final apiAddress = 'https://homelab.marinodev.com';
|
final apiAddress = 'https://homelab.marinodev.com';
|
||||||
SecretKey secretKey = SecretKey(Platform.environment['JOBLINK_SECRET_KEY']!);
|
SecretKey secretKey = SecretKey(Platform.environment['SECRET_KEY']!);
|
||||||
|
|
||||||
void main() async{
|
void main() async{
|
||||||
final jwt = JWT(
|
final jwt = JWT(
|
||||||
{'username': 'tmp'},
|
{
|
||||||
|
'username': 'tmp'
|
||||||
|
},
|
||||||
);
|
);
|
||||||
final token = jwt.sign(secretKey);
|
final token = jwt.sign(secretKey);
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ void main() async {
|
|||||||
"password": "tmp"
|
"password": "tmp"
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
var response = await http.post(Uri.parse('$apiAddress/fbla-api/createuser'),
|
var response = await http.post(Uri.parse('$apiAddress, /fbla-api/createuser'),
|
||||||
body: json,
|
body: json,
|
||||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||||
expect(response.statusCode, 200);
|
expect(response.statusCode, 200);
|
||||||
@ -69,9 +70,11 @@ void main() async {
|
|||||||
"username": "tmp"
|
"username": "tmp"
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
var response = await http.post(Uri.parse('$apiAddress/fbla-api/deleteuser'),
|
var response = await http.post(
|
||||||
|
Uri.parse('$apiAddress/fbla-api/deleteuser'),
|
||||||
body: json,
|
body: json,
|
||||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
headers: {'Authorization': token}).timeout(const Duration(seconds: 20)
|
||||||
|
);
|
||||||
expect(response.statusCode, 200);
|
expect(response.statusCode, 200);
|
||||||
expect(response.body, 'tmp');
|
expect(response.body, 'tmp');
|
||||||
});
|
});
|
||||||
@ -81,6 +84,7 @@ void main() async {
|
|||||||
"id": 0,
|
"id": 0,
|
||||||
"name": "tmp",
|
"name": "tmp",
|
||||||
"description": "tmp",
|
"description": "tmp",
|
||||||
|
"type": "business",
|
||||||
"website": "tmp",
|
"website": "tmp",
|
||||||
"contactName": "tmp",
|
"contactName": "tmp",
|
||||||
"contactEmail": "tmp",
|
"contactEmail": "tmp",
|
||||||
@ -90,8 +94,7 @@ void main() async {
|
|||||||
"locationAddress": "tmp"
|
"locationAddress": "tmp"
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
var response = await http.post(
|
var response = await http.post(Uri.parse('$apiAddress/fbla-api/createbusiness'),
|
||||||
Uri.parse('$apiAddress/fbla-api/createbusiness'),
|
|
||||||
body: json,
|
body: json,
|
||||||
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
headers: {'Authorization': token}).timeout(const Duration(seconds: 20));
|
||||||
|
|
||||||
|
|||||||
2
fbla_ui/Jenkinsfile
vendored
2
fbla_ui/Jenkinsfile
vendored
@ -3,7 +3,7 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage('Flutter Cleanup') {
|
stage('Flutter Cleanup') {
|
||||||
steps {
|
steps {
|
||||||
sh '''flutter upgrade
|
sh '''flutter upgrade --force
|
||||||
flutter pub upgrade
|
flutter pub upgrade
|
||||||
flutter --version
|
flutter --version
|
||||||
flutter doctor
|
flutter doctor
|
||||||
|
|||||||
@ -6,8 +6,6 @@ My version of the app can be found at [marinodev.com/fbla/](https://marinodev.co
|
|||||||
Pre-built files for several operating systems (built with my API) can be found in the releases tab,
|
Pre-built files for several operating systems (built with my API) can be found in the releases tab,
|
||||||
alternatively, you can compile it yourself for use with your own API and database (see API readme):
|
alternatively, you can compile it yourself for use with your own API and database (see API readme):
|
||||||
|
|
||||||
### Windows/Linux
|
|
||||||
|
|
||||||
1. Install [Flutter](https://docs.flutter.dev/get-started/install)
|
1. Install [Flutter](https://docs.flutter.dev/get-started/install)
|
||||||
2. Use `flutter doctor` to make sure your environment is fully set up for your platform
|
2. Use `flutter doctor` to make sure your environment is fully set up for your platform
|
||||||
3. Clone the repo
|
3. Clone the repo
|
||||||
@ -20,18 +18,3 @@ cd FBLA24/fbla_ui/
|
|||||||
4. Run `flutter pub get` to install all dependencies
|
4. Run `flutter pub get` to install all dependencies
|
||||||
5. Optional: set `apiAddress` at the top of `lib/api_logic.dart`
|
5. Optional: set `apiAddress` at the top of `lib/api_logic.dart`
|
||||||
6. Build app with `flutter build --release`
|
6. Build app with `flutter build --release`
|
||||||
|
|
||||||
### MacOS
|
|
||||||
|
|
||||||
*These instructions are temporary and will change as I try MacOS*
|
|
||||||
|
|
||||||
1. Install [Flutter](https://docs.flutter.dev/get-started/install)
|
|
||||||
2. Use `flutter doctor` to make sure your environment is fully set up for your platform
|
|
||||||
3. Clone the repo
|
|
||||||
```
|
|
||||||
git clone https://git.marinodev.com/MarinoDev/FBLA24.git
|
|
||||||
cd FBLA24/fbla_ui/
|
|
||||||
```
|
|
||||||
4. Run `flutter pub get` to install all dependencies
|
|
||||||
5. Optional: set `apiAddress` at the top of `lib/api_logic.dart`
|
|
||||||
6. Build app with `flutter build --release`
|
|
||||||
|
|||||||
@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
# The following line activates a set of recommended lints for Flutter apps,
|
# The following line activates a set of recommended lints for Flutter apps,
|
||||||
# packages, and plugins designed to encourage good coding practices.
|
# packages, and plugins designed to encourage good coding practices.
|
||||||
analyzer:
|
|
||||||
errors:
|
|
||||||
use_build_context_synchronously: ignore
|
|
||||||
include: package:flutter_lints/flutter.yaml
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
|
|||||||
@ -1,9 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id "com.android.application"
|
|
||||||
id "kotlin-android"
|
|
||||||
id "dev.flutter.flutter-gradle-plugin"
|
|
||||||
}
|
|
||||||
|
|
||||||
def localProperties = new Properties()
|
def localProperties = new Properties()
|
||||||
def localPropertiesFile = rootProject.file('local.properties')
|
def localPropertiesFile = rootProject.file('local.properties')
|
||||||
if (localPropertiesFile.exists()) {
|
if (localPropertiesFile.exists()) {
|
||||||
@ -12,6 +6,11 @@ if (localPropertiesFile.exists()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||||
|
if (flutterRoot == null) {
|
||||||
|
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||||
|
}
|
||||||
|
|
||||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||||
if (flutterVersionCode == null) {
|
if (flutterVersionCode == null) {
|
||||||
flutterVersionCode = '1'
|
flutterVersionCode = '1'
|
||||||
@ -22,6 +21,10 @@ if (flutterVersionName == null) {
|
|||||||
flutterVersionName = '1.0'
|
flutterVersionName = '1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "com.marinodev.fbla_ui"
|
namespace "com.marinodev.fbla_ui"
|
||||||
compileSdkVersion flutter.compileSdkVersion
|
compileSdkVersion flutter.compileSdkVersion
|
||||||
@ -66,4 +69,5 @@ flutter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,16 @@
|
|||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.7.10'
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:7.3.0'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
@ -9,7 +22,6 @@ rootProject.buildDir = '../build'
|
|||||||
subprojects {
|
subprojects {
|
||||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
project.evaluationDependsOn(':app')
|
project.evaluationDependsOn(':app')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,11 @@
|
|||||||
pluginManagement {
|
include ':app'
|
||||||
def flutterSdkPath = {
|
|
||||||
|
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
||||||
def properties = new Properties()
|
def properties = new Properties()
|
||||||
file("local.properties").withInputStream { properties.load(it) }
|
|
||||||
|
assert localPropertiesFile.exists()
|
||||||
|
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
|
||||||
|
|
||||||
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||||
return flutterSdkPath
|
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
|
||||||
}()
|
|
||||||
|
|
||||||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
|
||||||
id "com.android.application" version "7.3.0" apply false
|
|
||||||
id "org.jetbrains.kotlin.android" version "1.9.24" apply false
|
|
||||||
}
|
|
||||||
|
|
||||||
include ":app"
|
|
||||||
|
|||||||
@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="200mm"
|
|
||||||
height="70mm"
|
|
||||||
viewBox="0 0 200 70"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1"
|
|
||||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
|
||||||
sodipodi:docname="MDEVLogoFull.svg"
|
|
||||||
xml:space="preserve"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
|
||||||
id="namedview1"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#000000"
|
|
||||||
borderopacity="0.25"
|
|
||||||
inkscape:showpageshadow="2"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#d1d1d1"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
inkscape:zoom="0.75544332"
|
|
||||||
inkscape:cx="47.654138"
|
|
||||||
inkscape:cy="97.955728"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1046"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="0"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="layer1" /><defs
|
|
||||||
id="defs1"><rect
|
|
||||||
x="164.6723"
|
|
||||||
y="176.95522"
|
|
||||||
width="237.7821"
|
|
||||||
height="119.97466"
|
|
||||||
id="rect1047" /><rect
|
|
||||||
x="170.3439"
|
|
||||||
y="136.68353"
|
|
||||||
width="277.49832"
|
|
||||||
height="196.87138"
|
|
||||||
id="rect9139" /></defs><g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1"><path
|
|
||||||
style="font-size:48px;font-family:HeadlineNEWS;-inkscape-font-specification:HeadlineNEWS;white-space:pre;shape-padding:0.133618;fill:#000000;fill-opacity:1;stroke-width:0.608723"
|
|
||||||
d="m 103.58306,22.62203 h -7.380754 q 0,-2.975635 0,-5.95127 0,-4.113378 -0.233384,-5.74706 l -4.113377,8.489312 -3.617439,-0.08752 -3.82165,-8.401793 q -0.262556,1.779547 -0.291729,5.74706 0,2.975635 0,5.95127 h -7.380745 l 1.10857,-21.90884035 h 7.205708 l 5.105257,9.91878235 5.134429,-9.91878235 h 7.147374 z m 22.60912,0 h -5.68875 l -0.90436,-2.683906 h -7.20575 l -0.93354,2.683906 h -5.71792 L 112.7434,5.1182952 h 6.47642 z m -7.52665,-5.54285 -2.71309,-8.4601379 -2.65475,8.4601379 z m 27.62688,5.54285 h -6.12634 q -1.72121,-3.442402 -1.80873,-3.617439 -1.40031,-2.479696 -2.45054,-3.033981 l -1.72121,-0.904359 V 22.62203 H 128.4385 V 5.1182952 h 9.71463 q 2.77144,0 4.43431,1.050224 2.01294,1.2836072 2.01294,3.8799948 0,1.808719 -1.16692,2.888116 -0.81685,0.787668 -2.77145,1.51699 1.25445,0.583458 3.23821,3.850822 1.1961,2.158794 2.39219,4.317588 z m -7.29326,-12.194269 q 0,-2.4505225 -3.034,-2.4505225 h -1.77956 V 12.93663 h 1.77956 q 1.31279,0 2.15881,-0.612631 0.87519,-0.641804 0.87519,-1.896238 z m 15.66591,12.194269 h -6.068 V 5.1182952 h 6.068 z m 22.40489,0 h -5.33867 l -7.67251,-9.743746 0.20421,9.743746 h -5.74709 V 5.1182952 h 5.36784 l 7.76003,9.6562268 -0.26256,-9.6562268 h 5.68875 z m 22.02554,-8.839386 q 0,4.230069 -2.59639,6.709764 -2.59639,2.450523 -6.85563,2.450523 -4.23007,0 -6.85563,-2.42135 -2.62556,-2.42135 -2.62556,-6.622246 0,-4.1717228 2.71308,-6.6805917 2.62556,-2.4505228 6.85563,-2.4505228 4.11338,0 6.70976,2.4213499 2.65474,2.5088688 2.65474,6.5930736 z m -5.74706,0.02917 q 0,-1.808719 -0.96271,-2.946462 -0.9627,-1.1669148 -2.74225,-1.1669148 -1.83789,0 -2.77143,1.2252608 -0.87518,1.10857 -0.87518,2.975635 0,1.837892 0.87518,2.917289 0.93354,1.196089 2.71308,1.196089 3.76331,0 3.76331,-4.200897 z"
|
|
||||||
id="text9137"
|
|
||||||
inkscape:label="Marino"
|
|
||||||
aria-label="Marino" /><path
|
|
||||||
d="m 104.7848,29.612184 q 8.86861,0 14.46983,5.4456 5.60122,5.393746 5.60122,14.210437 0,8.505515 -5.18631,13.899254 -5.13446,5.341879 -13.58816,5.341879 H 86.114135 v -38.89717 z m 6.37918,19.500449 q 0,-4.200897 -2.1264,-6.690317 -2.28198,-2.696869 -6.43104,-2.696869 h -2.956187 v 18.774366 h 3.059917 q 4.25279,0 6.43104,-2.645003 2.02267,-2.437559 2.02267,-6.742177 z m 45.19311,19.396721 H 128.71401 V 29.560317 h 27.53935 v 8.92042 H 142.2503 v 5.964233 h 12.65462 v 8.868553 H 142.2503 v 6.327278 h 14.10679 z m 43.5333,-38.949037 -15.40328,38.949037 H 173.18098 L 157.31084,29.560317 h 14.41797 l 7.62387,23.234579 q 0.15559,-0.20745 7.31267,-23.234579 z"
|
|
||||||
id="text1045"
|
|
||||||
style="font-size:85.3333px;font-family:HeadlineNEWS;-inkscape-font-specification:HeadlineNEWS;letter-spacing:-4.66px;white-space:pre;fill:#000000;fill-opacity:1;stroke-width:0.608723"
|
|
||||||
inkscape:label="Dev"
|
|
||||||
aria-label="DEV" /><path
|
|
||||||
d="m 39.967467,0 c -1.24713,0 -2.07854,1.440059 -2.07854,1.440059 l -4.57281,7.920321 17.81611,30.858404 c 4.37185,-0.99615 6.86321,4.80385 3.14145,7.29302 -3.72178,2.48917 -8.13084,-2.02826 -5.54068,-5.68838 v 0 L 31.653287,12.240495 0.47509223,66.242704 c -0.55431396,0.96004 -0.62353496,1.80008 -0.20783896,2.52011 0.41568996,0.72005 1.17784883,1.08004 2.28640583,1.08004 h 9.1456049 l 17.816103,-30.8584 c -3.04862,-3.28806 0.72867,-8.34565 4.74522,-6.36708 4.01656,1.97857 2.30888,8.05564 -2.15596,7.64256 v 0 l -17.079704,29.58292 h 62.356384 c 0,0 1.66283,0 2.2864,-1.08004 0.62353,-1.08005 -0.20784,-2.52011 -0.20784,-2.52011 l -4.57281,-7.92032 h -35.63222 c -1.32322,4.28422 -7.59186,3.5418 -7.88666,-0.92594 -0.29484,-4.46773 5.82195,-6.02738 7.69662,-1.95418 v 0 h 34.15941 L 42.046017,1.440059 c 0,0 -0.83138,-1.440059 -2.07855,-1.440059"
|
|
||||||
style="display:inline;fill:#2096f3;fill-opacity:1;stroke:none;stroke-width:2.37548"
|
|
||||||
id="path395"
|
|
||||||
inkscape:label="triangle"
|
|
||||||
inkscape:transform-center-y="-11.666667" /></g></svg>
|
|
||||||
|
Before Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.5 KiB |
157
fbla_ui/lib/api_logic.dart
Normal file
157
fbla_ui/lib/api_logic.dart
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fbla_ui/shared.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
var apiAddress = 'https://homelab.marinodev.com/fbla-api';
|
||||||
|
var client = http.Client();
|
||||||
|
// var apiAddress = '192.168.0.114:8000';
|
||||||
|
// var apiLogoAddress = 'https://homelab.marinodev.com/fbla-api';
|
||||||
|
// var apiLogoAddress = 'http://192.168.0.114:8000';
|
||||||
|
|
||||||
|
Future fetchBusinessData() async {
|
||||||
|
try {
|
||||||
|
var response = await http
|
||||||
|
.get(Uri.parse('$apiAddress/businessdata'))
|
||||||
|
.timeout(const Duration(seconds: 20));
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
var decodedResponse = json.decode(response.body);
|
||||||
|
List<Business> businessList = List<Business>.from(
|
||||||
|
decodedResponse.map((json) => Business.fromJson(json)).toList());
|
||||||
|
return businessList;
|
||||||
|
} else {
|
||||||
|
return 'Error ${response.statusCode}! Please try again later!';
|
||||||
|
}
|
||||||
|
} on TimeoutException {
|
||||||
|
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
||||||
|
} on SocketException {
|
||||||
|
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future createBusiness(Business business, String jwt) async {
|
||||||
|
var json = '''
|
||||||
|
{
|
||||||
|
"id": ${business.id},
|
||||||
|
"name": "${business.name}",
|
||||||
|
"description": "${business.description}",
|
||||||
|
"type": "${business.type.name}",
|
||||||
|
"website": "${business.website}",
|
||||||
|
"contactName": "${business.contactName}",
|
||||||
|
"contactEmail": "${business.contactEmail}",
|
||||||
|
"contactPhone": "${business.contactPhone}",
|
||||||
|
"notes": "${business.notes}",
|
||||||
|
"locationName": "${business.locationName}",
|
||||||
|
"locationAddress": "${business.locationAddress}"
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
|
||||||
|
try {
|
||||||
|
var response = await http.post(Uri.parse('$apiAddress/createbusiness'),
|
||||||
|
body: json,
|
||||||
|
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
return response.body;
|
||||||
|
}
|
||||||
|
} on TimeoutException {
|
||||||
|
return 'Unable to connect to server (timeout). Please try again later';
|
||||||
|
} on SocketException {
|
||||||
|
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future deleteBusiness(Business business, String jwt) async {
|
||||||
|
var json = '''
|
||||||
|
{
|
||||||
|
"id": ${business.id}
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
|
||||||
|
try {
|
||||||
|
var response = await http.post(Uri.parse('$apiAddress/deletebusiness'),
|
||||||
|
body: json,
|
||||||
|
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
return response.body;
|
||||||
|
}
|
||||||
|
} on TimeoutException {
|
||||||
|
return 'Unable to connect to server (timeout). Please try again later';
|
||||||
|
} on SocketException {
|
||||||
|
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future editBusiness(Business business, String jwt) async {
|
||||||
|
var json = '''
|
||||||
|
{
|
||||||
|
"id": ${business.id},
|
||||||
|
"name": "${business.name}",
|
||||||
|
"description": "${business.description}",
|
||||||
|
"type": "${business.type.name}",
|
||||||
|
"website": "${business.website}",
|
||||||
|
"contactName": "${business.contactName}",
|
||||||
|
"contactEmail": "${business.contactEmail}",
|
||||||
|
"contactPhone": "${business.contactPhone}",
|
||||||
|
"notes": "${business.notes}",
|
||||||
|
"locationName": "${business.locationName}",
|
||||||
|
"locationAddress": "${business.locationAddress}"
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
print(json);
|
||||||
|
try {
|
||||||
|
var response = await http.post(Uri.parse('$apiAddress/editbusiness'),
|
||||||
|
body: json,
|
||||||
|
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
return response.body;
|
||||||
|
}
|
||||||
|
} on TimeoutException {
|
||||||
|
return 'Unable to connect to server (timeout). Please try again later';
|
||||||
|
} on SocketException {
|
||||||
|
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future signIn(String username, String password) async {
|
||||||
|
var json = '''
|
||||||
|
{
|
||||||
|
"username": "$username",
|
||||||
|
"password": "$password"
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
|
||||||
|
var response = await http.post(
|
||||||
|
Uri.parse('$apiAddress/signin'),
|
||||||
|
body: json,
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return response.body;
|
||||||
|
} else {
|
||||||
|
return 'Error: ${response.body}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future marinoDevLogo() async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse('$apiAddress/marinodev'),
|
||||||
|
);
|
||||||
|
|
||||||
|
// File logo = File ('${getTemporaryDirectory().toString()}/marinodev.svg');
|
||||||
|
// logo.writeAsBytes(response.bodyBytes);
|
||||||
|
|
||||||
|
return response.bodyBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future getLogo(int logoId) async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse('$apiAddress/logos/$logoId'),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return response.bodyBytes;
|
||||||
|
} else {
|
||||||
|
return 'Error ${response.statusCode}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,51 +1,37 @@
|
|||||||
import 'package:fbla_ui/pages/businesses_overview.dart';
|
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||||
|
import 'package:fbla_ui/api_logic.dart';
|
||||||
|
import 'package:fbla_ui/main.dart';
|
||||||
import 'package:fbla_ui/pages/create_edit_business.dart';
|
import 'package:fbla_ui/pages/create_edit_business.dart';
|
||||||
import 'package:fbla_ui/pages/create_edit_listing.dart';
|
import 'package:fbla_ui/pages/export_data.dart';
|
||||||
import 'package:fbla_ui/pages/listings_overview.dart';
|
import 'package:fbla_ui/pages/signin_page.dart';
|
||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
import 'package:fbla_ui/shared.dart';
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rive/rive.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
typedef Callback = void Function();
|
||||||
|
|
||||||
class Home extends StatefulWidget {
|
class Home extends StatefulWidget {
|
||||||
final void Function() themeCallback;
|
final Callback themeCallback;
|
||||||
final int? initialPage;
|
|
||||||
|
|
||||||
const Home({super.key, required this.themeCallback, this.initialPage});
|
const Home({super.key, required this.themeCallback});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Home> createState() => _HomeState();
|
State<Home> createState() => _HomeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomeState extends State<Home> {
|
class _HomeState extends State<Home> {
|
||||||
Set<JobType> jobTypeFilters = <JobType>{};
|
late Future refreshBusinessDataFuture;
|
||||||
Set<OfferType> offerTypeFilters = <OfferType>{};
|
bool _isPreviousData = false;
|
||||||
Set<BusinessType> businessTypeFilters = <BusinessType>{};
|
late List<Business> businesses;
|
||||||
String searchQuery = '';
|
|
||||||
late Future refreshBusinessDataOverviewJobFuture;
|
|
||||||
late Future refreshBusinessDataOverviewBusinessFuture;
|
|
||||||
int currentPageIndex = 0;
|
|
||||||
late dynamic previousJobData;
|
|
||||||
ScrollController scrollControllerBusinesses = ScrollController();
|
|
||||||
ScrollController scrollControllerJobs = ScrollController();
|
|
||||||
|
|
||||||
void _updateLoggedIn(bool updated) {
|
|
||||||
setState(() {
|
|
||||||
loggedIn = updated;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
currentPageIndex = widget.initialPage ?? 0;
|
refreshBusinessDataFuture = fetchBusinessData();
|
||||||
|
|
||||||
initialLogin();
|
initialLogin();
|
||||||
refreshBusinessDataOverviewJobFuture = fetchBusinessDataOverviewJobs();
|
|
||||||
refreshBusinessDataOverviewBusinessFuture =
|
|
||||||
fetchBusinessDataOverviewTypes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initialLogin() async {
|
Future<void> initialLogin() async {
|
||||||
@ -65,247 +51,399 @@ class _HomeState extends State<Home> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _updateOverviewBusinessesJobsCallback(
|
void setStateCallback() {
|
||||||
Set<JobType>? newJobTypeFilters,
|
|
||||||
Set<OfferType>? newOfferTypeFilters) async {
|
|
||||||
if (newJobTypeFilters != null) {
|
|
||||||
jobTypeFilters = Set.from(newJobTypeFilters);
|
|
||||||
}
|
|
||||||
if (newOfferTypeFilters != null) {
|
|
||||||
offerTypeFilters = Set.from(newOfferTypeFilters);
|
|
||||||
}
|
|
||||||
var refreshedData = fetchBusinessDataOverviewJobs(
|
|
||||||
typeFilters: jobTypeFilters, offerFilters: offerTypeFilters);
|
|
||||||
await refreshedData;
|
|
||||||
setState(() {
|
setState(() {
|
||||||
refreshBusinessDataOverviewJobFuture = refreshedData;
|
loggedIn = loggedIn;
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _updateOverviewBusinessesBusinessCallback(
|
|
||||||
Set<BusinessType>? newFilters) async {
|
|
||||||
if (newFilters != null) {
|
|
||||||
businessTypeFilters = Set.from(newFilters);
|
|
||||||
}
|
|
||||||
var refreshedData = fetchBusinessDataOverviewTypes(
|
|
||||||
typeFilters: businessTypeFilters.toList());
|
|
||||||
await refreshedData;
|
|
||||||
setState(() {
|
|
||||||
refreshBusinessDataOverviewBusinessFuture = refreshedData;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool widescreen = MediaQuery.sizeOf(context).width >= widescreenWidth;
|
bool widescreen = MediaQuery.sizeOf(context).width >= 1000;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
bottomNavigationBar: _getNavigationBar(widescreen),
|
floatingActionButton: _getFAB(),
|
||||||
body: RefreshIndicator(
|
body: RefreshIndicator(
|
||||||
edgeOffset: 145,
|
edgeOffset: 120,
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
_updateOverviewBusinessesJobsCallback(null, null);
|
var refreshedData = fetchBusinessData();
|
||||||
_updateOverviewBusinessesBusinessCallback(null);
|
await refreshedData;
|
||||||
},
|
|
||||||
child: widescreen
|
|
||||||
? Row(
|
|
||||||
children: [
|
|
||||||
_getNavigationRail(),
|
|
||||||
Expanded(
|
|
||||||
child: _ContentPane(
|
|
||||||
themeCallback: widget.themeCallback,
|
|
||||||
searchQuery: searchQuery,
|
|
||||||
currentPageIndex: currentPageIndex,
|
|
||||||
refreshBusinessDataOverviewBusinessFuture:
|
|
||||||
refreshBusinessDataOverviewBusinessFuture,
|
|
||||||
refreshBusinessDataOverviewJobFuture:
|
|
||||||
refreshBusinessDataOverviewJobFuture,
|
|
||||||
updateOverviewBusinessesBusinessCallback:
|
|
||||||
_updateOverviewBusinessesBusinessCallback,
|
|
||||||
updateOverviewBusinessesJobsCallback:
|
|
||||||
_updateOverviewBusinessesJobsCallback,
|
|
||||||
updateLoggedIn: _updateLoggedIn,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: _ContentPane(
|
|
||||||
themeCallback: widget.themeCallback,
|
|
||||||
searchQuery: searchQuery,
|
|
||||||
currentPageIndex: currentPageIndex,
|
|
||||||
refreshBusinessDataOverviewBusinessFuture:
|
|
||||||
refreshBusinessDataOverviewBusinessFuture,
|
|
||||||
refreshBusinessDataOverviewJobFuture:
|
|
||||||
refreshBusinessDataOverviewJobFuture,
|
|
||||||
updateOverviewBusinessesBusinessCallback:
|
|
||||||
_updateOverviewBusinessesBusinessCallback,
|
|
||||||
updateOverviewBusinessesJobsCallback:
|
|
||||||
_updateOverviewBusinessesJobsCallback,
|
|
||||||
updateLoggedIn: _updateLoggedIn,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? _getNavigationBar(bool widescreen) {
|
|
||||||
if (!widescreen) {
|
|
||||||
return NavigationBar(
|
|
||||||
selectedIndex: currentPageIndex,
|
|
||||||
indicatorColor: Theme.of(context).colorScheme.primary.withOpacity(0.5),
|
|
||||||
onDestinationSelected: (int index) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
currentPageIndex = index;
|
refreshBusinessDataFuture = refreshedData;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
destinations: <NavigationDestination>[
|
child: CustomScrollView(
|
||||||
NavigationDestination(
|
slivers: [
|
||||||
icon: const Icon(Icons.business_outlined),
|
SliverAppBar(
|
||||||
selectedIcon: Icon(
|
title: widescreen ? _searchBar() : const Text('Job Link'),
|
||||||
Icons.business,
|
toolbarHeight: 70,
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
pinned: true,
|
||||||
),
|
scrolledUnderElevation: 0,
|
||||||
label: 'Businesses'),
|
centerTitle: true,
|
||||||
NavigationDestination(
|
expandedHeight: widescreen ? 70 : 120,
|
||||||
icon: const Icon(Icons.work_outline),
|
backgroundColor: Theme.of(context).colorScheme.background,
|
||||||
selectedIcon: Icon(
|
bottom: _getBottom(),
|
||||||
Icons.work,
|
leading: IconButton(
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
icon: getIconFromThemeMode(themeMode),
|
||||||
),
|
|
||||||
label: 'Job Listings'),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getNavigationRail() {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
NavigationRail(
|
|
||||||
selectedIndex: currentPageIndex,
|
|
||||||
indicatorColor:
|
|
||||||
Theme.of(context).colorScheme.primary.withOpacity(0.5),
|
|
||||||
trailing: Expanded(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: IconButton(
|
|
||||||
iconSize: 30,
|
|
||||||
icon: Icon(
|
|
||||||
getIconFromThemeMode(themeMode),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.themeCallback();
|
widget.themeCallback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
actions: [
|
||||||
),
|
IconButton(
|
||||||
),
|
icon: const Icon(Icons.help),
|
||||||
leading: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 2.0, bottom: 8.0),
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/Triangle256.png',
|
|
||||||
height: 50,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (loggedIn)
|
|
||||||
FloatingActionButton(
|
|
||||||
heroTag: 'Homepage',
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (currentPageIndex == 0) {
|
showDialog(
|
||||||
Navigator.push(
|
context: context,
|
||||||
context,
|
builder: (BuildContext context) {
|
||||||
MaterialPageRoute(
|
return AlertDialog(
|
||||||
builder: (context) =>
|
title: const Text('About'),
|
||||||
const CreateEditBusiness()));
|
backgroundColor:
|
||||||
} else if (currentPageIndex == 1) {
|
Theme.of(context).colorScheme.background,
|
||||||
Navigator.push(
|
content: SizedBox(
|
||||||
context,
|
width: 500,
|
||||||
MaterialPageRoute(
|
child: IntrinsicHeight(
|
||||||
builder: (context) =>
|
child: Column(
|
||||||
const CreateEditJobListing()));
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
}
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Welcome to my FBLA 2024 Coding and Programming submission!\n\n'
|
||||||
|
'MarinoDev Job Link aims to provide comprehensive details of businesses and community partners'
|
||||||
|
' for Waukesha West High School\'s Career and Technical Education Department.\n\n'),
|
||||||
|
MouseRegion(
|
||||||
|
cursor: SystemMouseCursors.click,
|
||||||
|
child: GestureDetector(
|
||||||
|
child: const Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('Git Repo:'),
|
||||||
|
Text(
|
||||||
|
'https://git.marinodev.com/MarinoDev/FBLA24\n',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.blue)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
launchUrl(Uri.https(
|
||||||
|
'git.marinodev.com',
|
||||||
|
'/MarinoDev/FBLA24'));
|
||||||
},
|
},
|
||||||
child: const Icon(Icons.add),
|
),
|
||||||
|
),
|
||||||
|
MouseRegion(
|
||||||
|
cursor: SystemMouseCursors.click,
|
||||||
|
child: GestureDetector(
|
||||||
|
child: const Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Please direct any questions to'),
|
||||||
|
Text('drake@marinodev.com',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.blue)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
launchUrl(Uri.parse(
|
||||||
|
'mailto:drake@marinodev.com'));
|
||||||
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onDestinationSelected: (int index) {
|
),
|
||||||
setState(() {
|
),
|
||||||
currentPageIndex = index;
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: const Text('OK'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
labelType: NavigationRailLabelType.all,
|
|
||||||
destinations: <NavigationRailDestination>[
|
|
||||||
NavigationRailDestination(
|
|
||||||
icon: const Icon(Icons.business_outlined),
|
|
||||||
selectedIcon: Icon(
|
|
||||||
Icons.business,
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
),
|
||||||
label: const Text('Businesses')),
|
IconButton(
|
||||||
NavigationRailDestination(
|
icon: const Icon(Icons.picture_as_pdf),
|
||||||
icon: const Icon(Icons.work_outline),
|
onPressed: () async {
|
||||||
selectedIcon: Icon(
|
if (!_isPreviousData) {
|
||||||
Icons.work,
|
ScaffoldMessenger.of(context).clearSnackBars();
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
width: 300,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
content: Text('There is no data!'),
|
||||||
|
duration: Duration(seconds: 2),
|
||||||
),
|
),
|
||||||
label: const Text('Job Listings')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
selectedDataTypes = <DataType>{};
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
ExportData(businesses: businesses)));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
|
child: IconButton(
|
||||||
|
icon: loggedIn
|
||||||
|
? const Icon(Icons.account_circle)
|
||||||
|
: const Icon(Icons.login),
|
||||||
|
onPressed: () {
|
||||||
|
if (loggedIn) {
|
||||||
|
var payload = JWT.decode(jwt).payload;
|
||||||
|
|
||||||
class _ContentPane extends StatelessWidget {
|
showDialog(
|
||||||
final String searchQuery;
|
context: context,
|
||||||
final Future refreshBusinessDataOverviewBusinessFuture;
|
builder: (BuildContext context) {
|
||||||
final Future<void> Function(Set<BusinessType>)
|
return AlertDialog(
|
||||||
updateOverviewBusinessesBusinessCallback;
|
backgroundColor:
|
||||||
final void Function() themeCallback;
|
Theme.of(context).colorScheme.background,
|
||||||
final Future refreshBusinessDataOverviewJobFuture;
|
title: Text('Hi, ${payload['username']}!'),
|
||||||
final Future<void> Function(Set<JobType>?, Set<OfferType>?)
|
content: Text(
|
||||||
updateOverviewBusinessesJobsCallback;
|
'You are logged in as an admin with username ${payload['username']}.'),
|
||||||
final int currentPageIndex;
|
actions: [
|
||||||
final void Function(bool) updateLoggedIn;
|
TextButton(
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Logout'),
|
||||||
|
onPressed: () async {
|
||||||
|
final prefs = await SharedPreferences
|
||||||
|
.getInstance();
|
||||||
|
prefs.setBool('rememberMe', false);
|
||||||
|
prefs.setString('username', '');
|
||||||
|
prefs.setString('password', '');
|
||||||
|
|
||||||
const _ContentPane({
|
setState(() {
|
||||||
required this.searchQuery,
|
loggedIn = false;
|
||||||
required this.refreshBusinessDataOverviewBusinessFuture,
|
|
||||||
required this.updateOverviewBusinessesBusinessCallback,
|
|
||||||
required this.themeCallback,
|
|
||||||
required this.refreshBusinessDataOverviewJobFuture,
|
|
||||||
required this.updateOverviewBusinessesJobsCallback,
|
|
||||||
required this.currentPageIndex,
|
|
||||||
required this.updateLoggedIn,
|
|
||||||
});
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
@override
|
}),
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return IndexedStack(
|
|
||||||
index: currentPageIndex,
|
|
||||||
children: [
|
|
||||||
BusinessesOverview(
|
|
||||||
searchQuery: searchQuery,
|
|
||||||
refreshBusinessDataOverviewFuture:
|
|
||||||
refreshBusinessDataOverviewBusinessFuture,
|
|
||||||
updateBusinessesCallback: updateOverviewBusinessesBusinessCallback,
|
|
||||||
themeCallback: themeCallback,
|
|
||||||
updateLoggedIn: updateLoggedIn,
|
|
||||||
),
|
|
||||||
JobsOverview(
|
|
||||||
searchQuery: searchQuery,
|
|
||||||
refreshJobDataOverviewFuture: refreshBusinessDataOverviewJobFuture,
|
|
||||||
updateBusinessesCallback: updateOverviewBusinessesJobsCallback,
|
|
||||||
themeCallback: themeCallback,
|
|
||||||
updateLoggedIn: updateLoggedIn,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => SignInPage(
|
||||||
|
refreshAccount: setStateCallback)));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
FutureBuilder(
|
||||||
|
future: refreshBusinessDataFuture,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
if (snapshot.data.runtimeType == String) {
|
||||||
|
_isPreviousData = false;
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(children: [
|
||||||
|
Center(
|
||||||
|
child: Text(snapshot.data,
|
||||||
|
textAlign: TextAlign.center)),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: FilledButton(
|
||||||
|
child: const Text('Retry'),
|
||||||
|
onPressed: () {
|
||||||
|
var refreshedData = fetchBusinessData();
|
||||||
|
setState(() {
|
||||||
|
refreshBusinessDataFuture = refreshedData;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
businesses = snapshot.data;
|
||||||
|
_isPreviousData = true;
|
||||||
|
|
||||||
|
return BusinessDisplayPanel(
|
||||||
|
businesses: businesses,
|
||||||
|
widescreen: widescreen,
|
||||||
|
selectable: false);
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
||||||
|
child: Text(
|
||||||
|
'Error when loading data! Error: ${snapshot.error}'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else if (snapshot.connectionState ==
|
||||||
|
ConnectionState.waiting) {
|
||||||
|
if (_isPreviousData) {
|
||||||
|
return BusinessDisplayPanel(
|
||||||
|
businesses: businesses,
|
||||||
|
widescreen: widescreen,
|
||||||
|
selectable: false);
|
||||||
|
} else {
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
// child: const CircularProgressIndicator(),
|
||||||
|
child: const SizedBox(
|
||||||
|
width: 75,
|
||||||
|
height: 75,
|
||||||
|
child: RiveAnimation.asset(
|
||||||
|
'assets/mdev_triangle_loading.riv'),
|
||||||
|
// child: RiveAnimation.file(
|
||||||
|
// 'assets/mdev_triangle_loading.riv',
|
||||||
|
// ),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
'\nError: ${snapshot.error}',
|
||||||
|
style: const TextStyle(fontSize: 18),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 80,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _getFAB() {
|
||||||
|
if (loggedIn) {
|
||||||
|
return FloatingActionButton(
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const CreateEditBusiness()));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _searchBar() {
|
||||||
|
return SizedBox(
|
||||||
|
width: 800,
|
||||||
|
height: 50,
|
||||||
|
child: TextField(
|
||||||
|
onChanged: (query) {
|
||||||
|
setState(() {
|
||||||
|
searchFilter = query;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Search',
|
||||||
|
hintText: 'Search',
|
||||||
|
prefixIcon: const Padding(
|
||||||
|
padding: EdgeInsets.only(left: 8.0),
|
||||||
|
child: Icon(Icons.search),
|
||||||
|
),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||||
|
),
|
||||||
|
suffixIcon: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
|
child: IconButton(
|
||||||
|
tooltip: 'Filters',
|
||||||
|
icon: Icon(Icons.filter_list,
|
||||||
|
color: isFiltered
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onBackground),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
// DO NOT MOVE TO SEPARATE WIDGET, setState is needed in main tree
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.background,
|
||||||
|
title: const Text('Filter Options'),
|
||||||
|
content: const FilterChips(),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Reset'),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
filters = <BusinessType>{};
|
||||||
|
selectedChips = <BusinessType>{};
|
||||||
|
isFiltered = false;
|
||||||
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
onPressed: () {
|
||||||
|
selectedChips = Set.from(filters);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Apply'),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
filters = Set.from(selectedChips);
|
||||||
|
if (filters.isNotEmpty) {
|
||||||
|
isFiltered = true;
|
||||||
|
} else {
|
||||||
|
isFiltered = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferredSizeWidget? _getBottom() {
|
||||||
|
if (MediaQuery.sizeOf(context).width <= 1000) {
|
||||||
|
return PreferredSize(
|
||||||
|
preferredSize: const Size.fromHeight(0),
|
||||||
|
child: SizedBox(
|
||||||
|
// color: Theme.of(context).colorScheme.background,
|
||||||
|
height: 70,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: _searchBar(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import 'package:fbla_ui/home.dart';
|
import 'package:fbla_ui/home.dart';
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
ThemeMode themeMode = ThemeMode.system;
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
@ -21,35 +22,16 @@ void main() async {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Main app page loader and theme manager
|
|
||||||
class MainApp extends StatefulWidget {
|
class MainApp extends StatefulWidget {
|
||||||
final int? initialPage;
|
final bool? isDark;
|
||||||
|
|
||||||
const MainApp({super.key, this.initialPage});
|
const MainApp({super.key, this.isDark});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MainApp> createState() => _MainAppState();
|
State<MainApp> createState() => _MainAppState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MainAppState extends State<MainApp> {
|
class _MainAppState extends State<MainApp> {
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// prevent landscape mode (it looks bad)
|
|
||||||
SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
DeviceOrientation.portraitDown,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return MaterialApp(
|
|
||||||
title: 'Job Link',
|
|
||||||
themeMode: themeMode,
|
|
||||||
darkTheme: _darkThemeData(),
|
|
||||||
theme: _lightThemeData(),
|
|
||||||
home: Home(themeCallback: _switchTheme, initialPage: widget.initialPage),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Switch the theme mode based on the currently selected theme and the system prefs
|
|
||||||
void _switchTheme() async {
|
void _switchTheme() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
if (MediaQuery.of(context).platformBrightness == Brightness.dark &&
|
if (MediaQuery.of(context).platformBrightness == Brightness.dark &&
|
||||||
@ -77,76 +59,45 @@ class _MainAppState extends State<MainApp> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Static theme for dark mode
|
@override
|
||||||
ThemeData _darkThemeData() {
|
Widget build(BuildContext context) {
|
||||||
return ThemeData(
|
SystemChrome.setPreferredOrientations([
|
||||||
scaffoldBackgroundColor: const Color(0xFF121212),
|
DeviceOrientation.portraitUp,
|
||||||
|
DeviceOrientation.portraitDown,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return MaterialApp(
|
||||||
|
title: 'Job Link',
|
||||||
|
themeMode: themeMode,
|
||||||
|
// themeMode: ThemeMode.light,
|
||||||
|
darkTheme: ThemeData(
|
||||||
colorScheme: ColorScheme.dark(
|
colorScheme: ColorScheme.dark(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
primary: Colors.blue.shade700,
|
primary: Colors.blue,
|
||||||
onPrimary: Colors.white,
|
onPrimary: Colors.white,
|
||||||
secondary: Colors.blue.shade900,
|
secondary: Colors.blue.shade900,
|
||||||
onSecondary: Colors.white,
|
background: const Color.fromARGB(255, 31, 31, 31),
|
||||||
surface: const Color.fromARGB(255, 31, 31, 31),
|
|
||||||
surfaceContainer: const Color.fromARGB(255, 46, 46, 46),
|
|
||||||
tertiary: Colors.green.shade900,
|
tertiary: Colors.green.shade900,
|
||||||
),
|
),
|
||||||
iconTheme: const IconThemeData(color: Colors.white),
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
|
inputDecorationTheme: const InputDecorationTheme(),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey.withOpacity(0.1),
|
|
||||||
labelStyle: const TextStyle(color: Colors.grey),
|
|
||||||
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
|
||||||
if (states.contains(WidgetState.focused) &&
|
|
||||||
!states.contains(WidgetState.hovered)) {
|
|
||||||
return TextStyle(color: Colors.blue.shade700);
|
|
||||||
}
|
|
||||||
return const TextStyle(color: Colors.grey);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
dropdownMenuTheme: const DropdownMenuThemeData(
|
theme: ThemeData(
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Static theme for light mode
|
|
||||||
ThemeData _lightThemeData() {
|
|
||||||
return ThemeData(
|
|
||||||
scaffoldBackgroundColor: Colors.grey.shade300,
|
|
||||||
colorScheme: ColorScheme.light(
|
colorScheme: ColorScheme.light(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
primary: Colors.blue.shade700,
|
primary: Colors.blue,
|
||||||
onPrimary: Colors.white,
|
onPrimary: Colors.white,
|
||||||
secondary: Colors.blue.shade300,
|
secondary: Colors.blue.shade200,
|
||||||
onSecondary: Colors.black,
|
background: Colors.white,
|
||||||
surface: Colors.grey.shade100,
|
|
||||||
surfaceContainer: Colors.grey.shade200,
|
|
||||||
tertiary: Colors.green,
|
tertiary: Colors.green,
|
||||||
),
|
),
|
||||||
iconTheme: const IconThemeData(color: Colors.black),
|
iconTheme: const IconThemeData(color: Colors.black),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme:
|
||||||
// border: OutlineInputBorder(),
|
const InputDecorationTheme(border: UnderlineInputBorder()),
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey.withOpacity(0.25),
|
|
||||||
labelStyle: TextStyle(color: Colors.grey.shade700),
|
|
||||||
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
|
||||||
if (states.contains(WidgetState.focused) &&
|
|
||||||
!states.contains(WidgetState.hovered)) {
|
|
||||||
return TextStyle(color: Colors.blue.shade700);
|
|
||||||
}
|
|
||||||
return TextStyle(color: Colors.grey.shade700);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
dropdownMenuTheme: const DropdownMenuThemeData(
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
|
),
|
||||||
|
home: Home(themeCallback: _switchTheme),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,249 +1,172 @@
|
|||||||
|
import 'package:fbla_ui/api_logic.dart';
|
||||||
import 'package:fbla_ui/main.dart';
|
import 'package:fbla_ui/main.dart';
|
||||||
import 'package:fbla_ui/pages/create_edit_business.dart';
|
import 'package:fbla_ui/pages/create_edit_business.dart';
|
||||||
import 'package:fbla_ui/pages/create_edit_listing.dart';
|
import 'package:fbla_ui/pages/signin_page.dart';
|
||||||
import 'package:fbla_ui/pages/listing_detail.dart';
|
import 'package:fbla_ui/shared.dart';
|
||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:fbla_ui/shared/widgets.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:rive/rive.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class BusinessDetail extends StatefulWidget {
|
class BusinessDetail extends StatefulWidget {
|
||||||
final int id;
|
final Business inputBusiness;
|
||||||
final String name;
|
|
||||||
|
|
||||||
const BusinessDetail({super.key, required this.id, required this.name});
|
const BusinessDetail({super.key, required this.inputBusiness});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<BusinessDetail> createState() => _CreateBusinessDetailState();
|
State<BusinessDetail> createState() => _CreateBusinessDetailState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CreateBusinessDetailState extends State<BusinessDetail> {
|
class _CreateBusinessDetailState extends State<BusinessDetail> {
|
||||||
late Future loadBusiness;
|
|
||||||
bool _isRetrying = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
loadBusiness = fetchBusiness(widget.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder(
|
Business business = Business.copy(widget.inputBusiness);
|
||||||
future: loadBusiness,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
if (snapshot.data.runtimeType != String) {
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(snapshot.data.name),
|
title: Text(business.name),
|
||||||
actions: _getActions(snapshot.data),
|
actions: _getActions(business),
|
||||||
),
|
),
|
||||||
body: _detailBody(snapshot.data),
|
body: ListView(
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(widget.name),
|
|
||||||
),
|
|
||||||
body: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(children: [
|
|
||||||
Center(
|
|
||||||
child:
|
|
||||||
Text(snapshot.data, textAlign: TextAlign.center)),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: FilledButton(
|
|
||||||
child: const Text('Retry'),
|
|
||||||
onPressed: () async {
|
|
||||||
if (!_isRetrying) {
|
|
||||||
setState(() {
|
|
||||||
_isRetrying = true;
|
|
||||||
});
|
|
||||||
var refreshedData =
|
|
||||||
await fetchBusiness(widget.id);
|
|
||||||
setState(() {
|
|
||||||
loadBusiness = refreshedData;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (snapshot.connectionState == ConnectionState.waiting) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(widget.name),
|
|
||||||
),
|
|
||||||
body: Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: const SizedBox(
|
|
||||||
width: 75,
|
|
||||||
height: 75,
|
|
||||||
child:
|
|
||||||
RiveAnimation.asset('assets/mdev_triangle_loading.riv'),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(widget.name),
|
|
||||||
),
|
|
||||||
body: Text(
|
|
||||||
'\nError: ${snapshot.error}',
|
|
||||||
style: const TextStyle(fontSize: 18),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _detailBody(Business business) {
|
|
||||||
return ListView(
|
|
||||||
children: [
|
children: [
|
||||||
// Title, logo, desc, website
|
Card(
|
||||||
Center(
|
clipBehavior: Clip.antiAlias,
|
||||||
child: SizedBox(
|
|
||||||
width: 800,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
ListTile(
|
||||||
padding: const EdgeInsets.only(top: 4.0),
|
title: Text(business.name,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24, fontWeight: FontWeight.bold)),
|
||||||
|
subtitle: Text(
|
||||||
|
business.description,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
),
|
||||||
|
leading: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(6.0),
|
||||||
|
child: Image.network(
|
||||||
|
'https://$apiAddress/fbla-api/logos/${business.id}',
|
||||||
|
width: 48,
|
||||||
|
height: 48, errorBuilder: (BuildContext context,
|
||||||
|
Object exception, StackTrace? stackTrace) {
|
||||||
|
return getIconFromType(business.type, 48,
|
||||||
|
Theme.of(context).colorScheme.onSurface);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.link),
|
||||||
|
title: const Text('Website'),
|
||||||
|
subtitle: Text(business.website,
|
||||||
|
style: const TextStyle(color: Colors.blue)),
|
||||||
|
onTap: () {
|
||||||
|
launchUrl(Uri.parse('https://${business.website}'));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: (business.contactEmail.isNotEmpty ||
|
||||||
|
business.contactPhone.isNotEmpty),
|
||||||
child: Card(
|
child: Card(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 8.0),
|
padding: const EdgeInsets.only(left: 16.0, top: 8.0),
|
||||||
child: ListTile(
|
child: Text(
|
||||||
titleAlignment: ListTileTitleAlignment.titleHeight,
|
business.contactName.isEmpty
|
||||||
title: Text(business.name!,
|
? 'Contact ${business.name}'
|
||||||
|
: business.contactName,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24, fontWeight: FontWeight.bold)),
|
fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
subtitle: Text(
|
|
||||||
business.description!,
|
|
||||||
),
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.only(bottom: 8, left: 16),
|
|
||||||
leading: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(6.0),
|
|
||||||
child: Image.network(
|
|
||||||
'$apiAddress/logos/${business.id}',
|
|
||||||
width: 48,
|
|
||||||
height: 48, errorBuilder:
|
|
||||||
(BuildContext context, Object exception,
|
|
||||||
StackTrace? stackTrace) {
|
|
||||||
return Icon(
|
|
||||||
getIconFromBusinessType(
|
|
||||||
business.type ?? BusinessType.other),
|
|
||||||
size: 48);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
if (business.website != null)
|
Visibility(
|
||||||
ListTile(
|
visible: business.contactPhone.isNotEmpty,
|
||||||
leading: const Icon(Icons.link),
|
child: ListTile(
|
||||||
title: const Text('Website'),
|
leading: Icon(Icons.phone),
|
||||||
subtitle: Text(
|
title: Text(business.contactPhone),
|
||||||
business.website!
|
|
||||||
.replaceAll('https://', '')
|
|
||||||
.replaceAll('http://', '')
|
|
||||||
.replaceAll('www.', ''),
|
|
||||||
style: const TextStyle(color: Colors.blue)),
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
launchUrl(Uri.parse(business.website!));
|
showDialog(
|
||||||
},
|
context: context,
|
||||||
),
|
builder: (BuildContext context) {
|
||||||
],
|
return AlertDialog(
|
||||||
),
|
backgroundColor:
|
||||||
),
|
Theme.of(context).colorScheme.background,
|
||||||
),
|
title: Text(business.contactName.isEmpty
|
||||||
// Available positions
|
? 'Contact ${business.name}?'
|
||||||
if (business.listings != null || loggedIn)
|
: 'Contact ${business.contactName}'),
|
||||||
Card(
|
content: Text(business.contactName.isEmpty
|
||||||
clipBehavior: Clip.antiAlias,
|
? 'Would you like to call or text ${business.name}?'
|
||||||
child: Column(
|
: 'Would you like to call or text ${business.contactName}?'),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
actions: [
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16, top: 8),
|
|
||||||
child: _GetListingsTitle(business)),
|
|
||||||
if (business.listings != null)
|
|
||||||
_JobList(business: business)
|
|
||||||
else
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0),
|
|
||||||
child: Text('No job listings exist.'),
|
|
||||||
),
|
|
||||||
TextButton(
|
TextButton(
|
||||||
child: const Text('add one?'),
|
child: const Text('Text'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).push(
|
launchUrl(Uri.parse(
|
||||||
MaterialPageRoute(
|
'sms:${business.contactPhone}'));
|
||||||
builder: (context) =>
|
Navigator.of(context).pop();
|
||||||
CreateEditJobListing(
|
}),
|
||||||
inputBusiness: business,
|
TextButton(
|
||||||
)));
|
child: const Text('Call'),
|
||||||
|
onPressed: () async {
|
||||||
|
launchUrl(Uri.parse(
|
||||||
|
'tel:${business.contactPhone}'));
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: business.contactEmail.isNotEmpty,
|
||||||
|
child: ListTile(
|
||||||
|
leading: const Icon(Icons.email),
|
||||||
|
title: Text(business.contactEmail),
|
||||||
|
onTap: () {
|
||||||
|
launchUrl(Uri.parse('mailto:${business.contactEmail}'));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
// Contact info
|
),
|
||||||
ContactInformationCard(business: business),
|
Visibility(
|
||||||
// Location
|
child: Card(
|
||||||
Card(
|
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.location_on),
|
leading: const Icon(Icons.location_on),
|
||||||
title: Text(business.locationName),
|
title: Text(business.locationName),
|
||||||
subtitle: Text(business.locationAddress!),
|
subtitle: Text(business.locationAddress),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
launchUrl(Uri.parse(Uri.encodeFull(
|
launchUrl(Uri.parse(Uri.encodeFull(
|
||||||
'https://www.google.com/maps/search/?api=1&query=${business.locationName} ${business.locationAddress}')));
|
'https://www.google.com/maps/search/?api=1&query=${business.locationName}')));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Notes
|
),
|
||||||
if (business.notes != null && business.notes != '')
|
Visibility(
|
||||||
Card(
|
visible: business.notes.isNotEmpty,
|
||||||
|
child: Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.notes),
|
leading: const Icon(Icons.notes),
|
||||||
title: const Text(
|
title: const Text(
|
||||||
'Additional Notes',
|
'Additional Notes:',
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
fontSize: 20, fontWeight: FontWeight.bold),
|
|
||||||
),
|
),
|
||||||
subtitle: Text(business.notes!),
|
subtitle: Text(business.notes),
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,9 +177,8 @@ class _CreateBusinessDetailState extends State<BusinessDetail> {
|
|||||||
icon: const Icon(Icons.edit),
|
icon: const Icon(Icons.edit),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
builder: (context) => CreateEditBusiness(
|
builder: (context) =>
|
||||||
inputBusiness: business,
|
CreateEditBusiness(inputBusiness: business)));
|
||||||
)));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
@ -266,7 +188,7 @@ class _CreateBusinessDetailState extends State<BusinessDetail> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: Theme.of(context).colorScheme.background,
|
||||||
title: const Text('Are You Sure?'),
|
title: const Text('Are You Sure?'),
|
||||||
content:
|
content:
|
||||||
Text('This will permanently delete ${business.name}.'),
|
Text('This will permanently delete ${business.name}.'),
|
||||||
@ -280,7 +202,7 @@ class _CreateBusinessDetailState extends State<BusinessDetail> {
|
|||||||
child: const Text('Yes'),
|
child: const Text('Yes'),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
String? deleteResult =
|
String? deleteResult =
|
||||||
await deleteBusiness(business.id);
|
await deleteBusiness(business, jwt);
|
||||||
if (deleteResult != null) {
|
if (deleteResult != null) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@ -304,107 +226,3 @@ class _CreateBusinessDetailState extends State<BusinessDetail> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _JobList extends StatelessWidget {
|
|
||||||
final Business business;
|
|
||||||
|
|
||||||
const _JobList({required this.business});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<_JobListItem> listItems = [];
|
|
||||||
for (JobListing listing in business.listings!) {
|
|
||||||
listItems.add(_JobListItem(
|
|
||||||
jobListing: listing,
|
|
||||||
fromBusiness: business,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return ListView(
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: listItems,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _JobListItem extends StatelessWidget {
|
|
||||||
final JobListing jobListing;
|
|
||||||
final Business fromBusiness;
|
|
||||||
|
|
||||||
const _JobListItem({required this.jobListing, required this.fromBusiness});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ListTile(
|
|
||||||
leading: Icon(getIconFromJobType(jobListing.type!)),
|
|
||||||
title: Text(jobListing.name),
|
|
||||||
subtitle: Text(
|
|
||||||
jobListing.description,
|
|
||||||
style: const TextStyle(overflow: TextOverflow.ellipsis),
|
|
||||||
maxLines: 2,
|
|
||||||
),
|
|
||||||
trailing: _getEditIcon(context, fromBusiness, jobListing),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => JobListingDetail(
|
|
||||||
listing: jobListing,
|
|
||||||
fromBusiness: fromBusiness,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? _getEditIcon(
|
|
||||||
BuildContext context, Business fromBusiness, JobListing inputListing) {
|
|
||||||
if (loggedIn) {
|
|
||||||
return IconButton(
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.edit,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => CreateEditJobListing(
|
|
||||||
inputBusiness: fromBusiness,
|
|
||||||
inputJobListing: inputListing,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GetListingsTitle extends StatelessWidget {
|
|
||||||
final Business fromBusiness;
|
|
||||||
|
|
||||||
const _GetListingsTitle(this.fromBusiness);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (!loggedIn) {
|
|
||||||
return Text(
|
|
||||||
'Available Postitions (${fromBusiness.listings?.length ?? '0'})',
|
|
||||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold));
|
|
||||||
} else {
|
|
||||||
return Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text('Available Postitions (${fromBusiness.listings?.length ?? '0'})',
|
|
||||||
style:
|
|
||||||
const TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 24.0),
|
|
||||||
child: IconButton(
|
|
||||||
icon: const Icon(Icons.add),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => CreateEditJobListing(
|
|
||||||
inputBusiness: fromBusiness,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,601 +0,0 @@
|
|||||||
import 'package:fbla_ui/pages/business_detail.dart';
|
|
||||||
import 'package:fbla_ui/pages/create_edit_business.dart';
|
|
||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
|
||||||
import 'package:fbla_ui/shared/export.dart';
|
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:fbla_ui/shared/widgets.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
|
|
||||||
import 'package:rive/rive.dart';
|
|
||||||
import 'package:sliver_tools/sliver_tools.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
class BusinessesOverview extends StatefulWidget {
|
|
||||||
final String searchQuery;
|
|
||||||
final Future refreshBusinessDataOverviewFuture;
|
|
||||||
final Future<void> Function(Set<BusinessType>) updateBusinessesCallback;
|
|
||||||
final void Function() themeCallback;
|
|
||||||
final void Function(bool) updateLoggedIn;
|
|
||||||
|
|
||||||
const BusinessesOverview({
|
|
||||||
super.key,
|
|
||||||
required this.searchQuery,
|
|
||||||
required this.refreshBusinessDataOverviewFuture,
|
|
||||||
required this.updateBusinessesCallback,
|
|
||||||
required this.themeCallback,
|
|
||||||
required this.updateLoggedIn,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<BusinessesOverview> createState() => _BusinessesOverviewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _BusinessesOverviewState extends State<BusinessesOverview> {
|
|
||||||
bool _isPreviousData = false;
|
|
||||||
late Map<BusinessType, List<Business>> overviewBusinesses;
|
|
||||||
Set<BusinessType> businessTypeFilters = <BusinessType>{};
|
|
||||||
String searchQuery = '';
|
|
||||||
ScrollController controller = ScrollController();
|
|
||||||
bool _extended = true;
|
|
||||||
double prevPixelPosition = 0;
|
|
||||||
bool _isRetrying = false;
|
|
||||||
|
|
||||||
Map<BusinessType, List<Business>> _filterBySearch(
|
|
||||||
Map<BusinessType, List<Business>> businesses, String query) {
|
|
||||||
Map<BusinessType, List<Business>> filteredBusinesses = {};
|
|
||||||
|
|
||||||
for (BusinessType businessType in businesses.keys) {
|
|
||||||
filteredBusinesses[businessType] = List.from(businesses[businessType]!
|
|
||||||
.where((element) => element.name!
|
|
||||||
.replaceAll(RegExp(r'[^a-zA-Z]'), '')
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(query
|
|
||||||
.replaceAll(RegExp(r'[^a-zA-Z]'), '')
|
|
||||||
.toLowerCase()
|
|
||||||
.trim())));
|
|
||||||
}
|
|
||||||
|
|
||||||
filteredBusinesses.removeWhere((key, value) => value.isEmpty);
|
|
||||||
return filteredBusinesses;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _setSearch(String search) async {
|
|
||||||
setState(() {
|
|
||||||
searchQuery = search;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _setFilters(Set<BusinessType> filters) async {
|
|
||||||
businessTypeFilters = Set.from(filters);
|
|
||||||
widget.updateBusinessesCallback(businessTypeFilters);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _scrollListener() {
|
|
||||||
if ((prevPixelPosition - controller.position.pixels).abs() > 10) {
|
|
||||||
setState(() {
|
|
||||||
_extended =
|
|
||||||
controller.position.userScrollDirection == ScrollDirection.forward;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
prevPixelPosition = controller.position.pixels;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _generatePDF() {
|
|
||||||
List<Business> allBusinesses = [];
|
|
||||||
for (List<Business> businessList
|
|
||||||
in _filterBySearch(overviewBusinesses, searchQuery).values) {
|
|
||||||
allBusinesses.addAll(businessList);
|
|
||||||
}
|
|
||||||
|
|
||||||
generatePDF(
|
|
||||||
context: context,
|
|
||||||
documentTypeIndex: 0,
|
|
||||||
selectedBusinesses: Set.from(allBusinesses));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
controller.addListener(_scrollListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
bool widescreen = MediaQuery.sizeOf(context).width >= widescreenWidth;
|
|
||||||
return Scaffold(
|
|
||||||
floatingActionButton: _getFAB(widescreen),
|
|
||||||
body: CustomScrollView(
|
|
||||||
controller: controller,
|
|
||||||
slivers: [
|
|
||||||
MainSliverAppBar(
|
|
||||||
widescreen: widescreen,
|
|
||||||
setSearch: _setSearch,
|
|
||||||
searchHintText: 'Search Businesses',
|
|
||||||
themeCallback: widget.themeCallback,
|
|
||||||
filterIconButton: _filterIconButton(
|
|
||||||
businessTypeFilters,
|
|
||||||
),
|
|
||||||
updateLoggedIn: widget.updateLoggedIn,
|
|
||||||
generatePDF: _generatePDF,
|
|
||||||
),
|
|
||||||
FutureBuilder(
|
|
||||||
future: widget.refreshBusinessDataOverviewFuture,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
if (snapshot.data.runtimeType == String) {
|
|
||||||
_isPreviousData = false;
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(children: [
|
|
||||||
Center(
|
|
||||||
child: Text(snapshot.data,
|
|
||||||
textAlign: TextAlign.center)),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: FilledButton(
|
|
||||||
child: const Text('Retry'),
|
|
||||||
onPressed: () async {
|
|
||||||
if (!_isRetrying) {
|
|
||||||
setState(() {
|
|
||||||
_isRetrying = true;
|
|
||||||
});
|
|
||||||
await widget.updateBusinessesCallback(
|
|
||||||
businessTypeFilters);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
overviewBusinesses = snapshot.data;
|
|
||||||
_isPreviousData = true;
|
|
||||||
|
|
||||||
return BusinessDisplayPanel(
|
|
||||||
groupedBusinesses:
|
|
||||||
_filterBySearch(overviewBusinesses, searchQuery),
|
|
||||||
widescreen: widescreen,
|
|
||||||
);
|
|
||||||
} else if (snapshot.hasError) {
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
|
||||||
child: Text(
|
|
||||||
'Error when loading data! Error: ${snapshot.error}'),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else if (snapshot.connectionState ==
|
|
||||||
ConnectionState.waiting) {
|
|
||||||
if (_isPreviousData) {
|
|
||||||
return BusinessDisplayPanel(
|
|
||||||
groupedBusinesses:
|
|
||||||
_filterBySearch(overviewBusinesses, searchQuery),
|
|
||||||
widescreen: widescreen,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: const SizedBox(
|
|
||||||
width: 75,
|
|
||||||
height: 75,
|
|
||||||
child: RiveAnimation.asset(
|
|
||||||
'assets/mdev_triangle_loading.riv'),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
'\nError: ${snapshot.error}',
|
|
||||||
style: const TextStyle(fontSize: 18),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _filterIconButton(Set<BusinessType> filters) {
|
|
||||||
Set<BusinessType> selectedChips = Set.from(filters);
|
|
||||||
|
|
||||||
return IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.filter_list,
|
|
||||||
color: filters.isNotEmpty
|
|
||||||
? Theme.of(context).colorScheme.primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
selectedChips = Set.from(businessTypeFilters);
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
void setDialogState(Set<BusinessType> newFilters) {
|
|
||||||
setState(() {
|
|
||||||
filters = newFilters;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> chips = [];
|
|
||||||
for (var type in BusinessType.values) {
|
|
||||||
chips.add(FilterChip(
|
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
showCheckmark: false,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
side: BorderSide(
|
|
||||||
color:
|
|
||||||
Theme.of(context).colorScheme.secondary)),
|
|
||||||
selectedColor: Theme.of(context).colorScheme.secondary,
|
|
||||||
label: Text(
|
|
||||||
getNameFromBusinessType(type),
|
|
||||||
style: TextStyle(
|
|
||||||
color: selectedChips.contains(type)
|
|
||||||
? Theme.of(context).colorScheme.onSecondary
|
|
||||||
: Theme.of(context).colorScheme.onSurface),
|
|
||||||
),
|
|
||||||
selected: selectedChips.contains(type),
|
|
||||||
onSelected: (bool selected) {
|
|
||||||
if (selected) {
|
|
||||||
selectedChips.add(type);
|
|
||||||
} else {
|
|
||||||
selectedChips.remove(type);
|
|
||||||
}
|
|
||||||
setDialogState(filters);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Filter Options'),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 400,
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8,
|
|
||||||
runSpacing: 8,
|
|
||||||
children: chips,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Reset'),
|
|
||||||
onPressed: () {
|
|
||||||
_setFilters(<BusinessType>{});
|
|
||||||
// selectedChips = <BusinessType>{};
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
onPressed: () {
|
|
||||||
// selectedChips = Set.from(filters);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Apply'),
|
|
||||||
onPressed: () {
|
|
||||||
_setFilters(selectedChips);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? _getFAB(bool widescreen) {
|
|
||||||
if (!widescreen && loggedIn) {
|
|
||||||
return FloatingActionButton.extended(
|
|
||||||
extendedIconLabelSpacing: _extended ? 8.0 : 0,
|
|
||||||
extendedPadding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
icon: const Icon(Icons.add),
|
|
||||||
label: AnimatedSize(
|
|
||||||
curve: Easing.standard,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
child: _extended ? const Text('Add Business') : Container(),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const CreateEditBusiness()));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class BusinessDisplayPanel extends StatefulWidget {
|
|
||||||
final Map<BusinessType, List<Business>> groupedBusinesses;
|
|
||||||
final bool widescreen;
|
|
||||||
|
|
||||||
const BusinessDisplayPanel({
|
|
||||||
super.key,
|
|
||||||
required this.groupedBusinesses,
|
|
||||||
required this.widescreen,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<BusinessDisplayPanel> createState() => _BusinessDisplayPanelState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _BusinessDisplayPanelState extends State<BusinessDisplayPanel> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (widget.groupedBusinesses.keys.isEmpty) {
|
|
||||||
return const SliverToBoxAdapter(
|
|
||||||
child: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: Text(
|
|
||||||
'No results found!\nPlease change your search filters.',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<_BusinessHeader> headers = [];
|
|
||||||
for (BusinessType businessType in widget.groupedBusinesses.keys) {
|
|
||||||
headers.add(_BusinessHeader(
|
|
||||||
businessType: businessType,
|
|
||||||
widescreen: widget.widescreen,
|
|
||||||
businesses: widget.groupedBusinesses[businessType]!));
|
|
||||||
}
|
|
||||||
headers
|
|
||||||
.sort((a, b) => a.businessType.index.compareTo(b.businessType.index));
|
|
||||||
return MultiSliver(children: headers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _BusinessHeader extends StatefulWidget {
|
|
||||||
final BusinessType businessType;
|
|
||||||
final List<Business> businesses;
|
|
||||||
final bool widescreen;
|
|
||||||
|
|
||||||
const _BusinessHeader({
|
|
||||||
required this.businessType,
|
|
||||||
required this.businesses,
|
|
||||||
required this.widescreen,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_BusinessHeader> createState() => _BusinessHeaderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _BusinessHeaderState extends State<_BusinessHeader> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SliverStickyHeader(
|
|
||||||
header: Container(
|
|
||||||
height: 55.0,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: _getHeaderRow(),
|
|
||||||
),
|
|
||||||
sliver: _getChildSliver(widget.businesses, widget.widescreen),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getHeaderRow() {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 4.0, right: 12.0),
|
|
||||||
child: Icon(
|
|
||||||
getIconFromBusinessType(widget.businessType),
|
|
||||||
color: Theme.of(context).colorScheme.onPrimary,
|
|
||||||
)),
|
|
||||||
Text(getNameFromBusinessType(widget.businessType),
|
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.onPrimary)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getChildSliver(List<Business> businesses, bool widescreen) {
|
|
||||||
if (widescreen) {
|
|
||||||
return SliverPadding(
|
|
||||||
padding: const EdgeInsets.all(4),
|
|
||||||
sliver: SliverGrid(
|
|
||||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
mainAxisExtent: 250.0,
|
|
||||||
maxCrossAxisExtent: 400.0,
|
|
||||||
mainAxisSpacing: 4.0,
|
|
||||||
crossAxisSpacing: 4.0,
|
|
||||||
),
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
childCount: businesses.length,
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
return _businessTile(
|
|
||||||
businesses[index],
|
|
||||||
widget.businessType,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
childCount: businesses.length,
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
return _businessListItem(
|
|
||||||
businesses[index],
|
|
||||||
widget.businessType,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A desktop widget that displays basic info about a business
|
|
||||||
Widget _businessTile(Business business, BusinessType jobType) {
|
|
||||||
return MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => BusinessDetail(
|
|
||||||
id: business.id,
|
|
||||||
name: business.name!,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
child: Card(
|
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(6.0),
|
|
||||||
child: Image.network('$apiAddress/logos/${business.id}',
|
|
||||||
height: 48,
|
|
||||||
width: 48, errorBuilder: (BuildContext context,
|
|
||||||
Object exception, StackTrace? stackTrace) {
|
|
||||||
return Icon(getIconFromBusinessType(business.type!),
|
|
||||||
size: 48);
|
|
||||||
}),
|
|
||||||
)),
|
|
||||||
Flexible(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
business.name!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18, fontWeight: FontWeight.bold),
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
business.description!,
|
|
||||||
maxLines: 5,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
if (business.website != null)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.link),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(Uri.parse(business.website!));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.location_on),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(Uri.parse(Uri.encodeFull(
|
|
||||||
'https://www.google.com/maps/search/?api=1&query=${business.locationName} ${business.locationAddress}')));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (business.contactPhone != null)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.phone),
|
|
||||||
onPressed: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.surface,
|
|
||||||
title:
|
|
||||||
Text('Contact ${business.contactName}'),
|
|
||||||
content: Text(
|
|
||||||
'Would you like to call or text ${business.contactName}?'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Text'),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(Uri.parse(
|
|
||||||
'sms:${business.contactPhone}'));
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Call'),
|
|
||||||
onPressed: () async {
|
|
||||||
launchUrl(Uri.parse(
|
|
||||||
'tel:${business.contactPhone}'));
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (business.contactEmail != null)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.email),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(
|
|
||||||
Uri.parse('mailto:${business.contactEmail}'));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A mobile widget that displays basic info about a business
|
|
||||||
Widget _businessListItem(Business business, BusinessType? jobType) {
|
|
||||||
return Card(
|
|
||||||
child: ListTile(
|
|
||||||
leading: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(3.0),
|
|
||||||
child: Image.network('$apiAddress/logos/${business.id}',
|
|
||||||
height: 24, width: 24, errorBuilder: (BuildContext context,
|
|
||||||
Object exception, StackTrace? stackTrace) {
|
|
||||||
return Icon(getIconFromBusinessType(business.type!));
|
|
||||||
})),
|
|
||||||
title: Text(business.name!),
|
|
||||||
subtitle: Text(business.description!,
|
|
||||||
maxLines: 2, overflow: TextOverflow.ellipsis),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => BusinessDetail(
|
|
||||||
id: business.id,
|
|
||||||
name: business.name!,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
|
import 'package:fbla_ui/api_logic.dart';
|
||||||
import 'package:fbla_ui/main.dart';
|
import 'package:fbla_ui/main.dart';
|
||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
import 'package:fbla_ui/shared.dart';
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
@ -24,23 +23,20 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
late TextEditingController _notesController;
|
late TextEditingController _notesController;
|
||||||
late TextEditingController _locationNameController;
|
late TextEditingController _locationNameController;
|
||||||
late TextEditingController _locationAddressController;
|
late TextEditingController _locationAddressController;
|
||||||
late bool widescreen;
|
|
||||||
|
|
||||||
Business business = Business(
|
Business business = Business(
|
||||||
id: 0,
|
id: 0,
|
||||||
name: 'Business',
|
name: 'Business',
|
||||||
description: 'Add details about the business below.',
|
description: 'Add details about the business below.',
|
||||||
type: null,
|
type: BusinessType.other,
|
||||||
website: null,
|
website: '',
|
||||||
contactName: null,
|
contactName: '',
|
||||||
contactEmail: null,
|
contactEmail: '',
|
||||||
contactPhone: null,
|
contactPhone: '',
|
||||||
notes: null,
|
notes: '',
|
||||||
locationName: '',
|
locationName: '',
|
||||||
locationAddress: null,
|
locationAddress: '',
|
||||||
);
|
);
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
String? dropDownErrorText;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -50,16 +46,11 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
_nameController = TextEditingController(text: business.name);
|
_nameController = TextEditingController(text: business.name);
|
||||||
_descriptionController =
|
_descriptionController =
|
||||||
TextEditingController(text: business.description);
|
TextEditingController(text: business.description);
|
||||||
business.type = widget.inputBusiness?.type;
|
|
||||||
} else {
|
} else {
|
||||||
_nameController = TextEditingController();
|
_nameController = TextEditingController();
|
||||||
_descriptionController = TextEditingController();
|
_descriptionController = TextEditingController();
|
||||||
}
|
}
|
||||||
_websiteController = TextEditingController(
|
_websiteController = TextEditingController(text: business.website);
|
||||||
text: business.website
|
|
||||||
?.replaceAll('https://', '')
|
|
||||||
.replaceAll('http://', '')
|
|
||||||
.replaceAll('www.', ''));
|
|
||||||
_contactNameController = TextEditingController(text: business.contactName);
|
_contactNameController = TextEditingController(text: business.contactName);
|
||||||
_contactPhoneController =
|
_contactPhoneController =
|
||||||
TextEditingController(text: business.contactPhone);
|
TextEditingController(text: business.contactPhone);
|
||||||
@ -73,10 +64,10 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final formKey = GlobalKey<FormState>();
|
final formKey = GlobalKey<FormState>();
|
||||||
|
final TextEditingController businessTypeController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
widescreen = MediaQuery.sizeOf(context).width >= widescreenWidth;
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: !_isLoading,
|
canPop: !_isLoading,
|
||||||
onPopInvoked: _handlePop,
|
onPopInvoked: _handlePop,
|
||||||
@ -88,14 +79,10 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
? Text('Edit ${widget.inputBusiness?.name}', maxLines: 1)
|
? Text('Edit ${widget.inputBusiness?.name}', maxLines: 1)
|
||||||
: const Text('Add New Business'),
|
: const Text('Add New Business'),
|
||||||
),
|
),
|
||||||
floatingActionButton: !widescreen
|
floatingActionButton: FloatingActionButton(
|
||||||
? FloatingActionButton.extended(
|
child: _isLoading
|
||||||
heroTag: 'saveBusiness',
|
? const Padding(
|
||||||
label: const Text('Save'),
|
padding: EdgeInsets.all(16.0),
|
||||||
icon: _isLoading
|
|
||||||
? const SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
strokeWidth: 3.0,
|
strokeWidth: 3.0,
|
||||||
@ -103,74 +90,86 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
)
|
)
|
||||||
: const Icon(Icons.save),
|
: const Icon(Icons.save),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (!_isLoading) {
|
if (formKey.currentState!.validate()) {
|
||||||
await _saveBusiness(context);
|
formKey.currentState?.save();
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
String? result;
|
||||||
|
// if (business.contactName == '') {
|
||||||
|
// business.contactName = 'Contact ${business.name}';
|
||||||
|
// }
|
||||||
|
if (widget.inputBusiness != null) {
|
||||||
|
result = await editBusiness(business, jwt);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
result = await createBusiness(business, jwt);
|
||||||
const SnackBar(
|
}
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
if (result != null) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
width: 400,
|
width: 400,
|
||||||
behavior: SnackBarBehavior.floating,
|
behavior: SnackBarBehavior.floating,
|
||||||
content: Text('Please wait for it to save.'),
|
content: Text(result)));
|
||||||
|
} else {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const MainApp()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: const Text('Check field inputs!'),
|
||||||
|
width: 200,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
: null,
|
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 800,
|
width: 1000,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
ListTile(
|
||||||
padding: const EdgeInsets.only(top: 4.0),
|
title: Text(business.name,
|
||||||
child: Card(
|
textAlign: TextAlign.left,
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 8.0),
|
|
||||||
child: ListTile(
|
|
||||||
titleAlignment:
|
|
||||||
ListTileTitleAlignment.titleHeight,
|
|
||||||
title: Text(business.name!,
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24, fontWeight: FontWeight.bold)),
|
||||||
fontWeight: FontWeight.bold)),
|
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
business.description!,
|
business.description,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
),
|
),
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.only(bottom: 8, left: 16),
|
|
||||||
leading: ClipRRect(
|
leading: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(6.0),
|
borderRadius: BorderRadius.circular(6.0),
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
'$apiAddress/clearbit/${Uri.encodeComponent(business.website ?? '')}',
|
|
||||||
width: 48,
|
width: 48,
|
||||||
height: 48, errorBuilder:
|
height: 48,
|
||||||
(BuildContext context,
|
'https://logo.clearbit.com/${business.website}',
|
||||||
Object exception,
|
errorBuilder: (BuildContext context,
|
||||||
StackTrace? stackTrace) {
|
Object exception, StackTrace? stackTrace) {
|
||||||
return Icon(
|
return getIconFromType(business.type, 48,
|
||||||
getIconFromBusinessType(business.type ??
|
Theme.of(context).colorScheme.onBackground);
|
||||||
BusinessType.other),
|
|
||||||
size: 48);
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Card(
|
Card(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
top: 8.0,
|
left: 8.0, right: 8.0),
|
||||||
bottom: 8.0,
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0),
|
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: _nameController,
|
controller: _nameController,
|
||||||
|
autovalidateMode:
|
||||||
|
AutovalidateMode.onUserInteraction,
|
||||||
maxLength: 30,
|
maxLength: 30,
|
||||||
onChanged: (inputName) {
|
onChanged: (inputName) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -181,10 +180,10 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Business Name (required)',
|
labelText: 'Business Name',
|
||||||
),
|
),
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value != null && value.trim().isEmpty) {
|
if (value != null && value.isEmpty) {
|
||||||
return 'Name is required';
|
return 'Name is required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -193,11 +192,41 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
bottom: 8.0, left: 8.0, right: 8.0),
|
left: 8.0, right: 8.0, bottom: 8.0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _websiteController,
|
||||||
|
autovalidateMode:
|
||||||
|
AutovalidateMode.onUserInteraction,
|
||||||
|
keyboardType: TextInputType.url,
|
||||||
|
onChanged: (inputUrl) {
|
||||||
|
business.website = Uri.encodeFull(inputUrl
|
||||||
|
.toLowerCase()
|
||||||
|
.replaceAll('https://', '')
|
||||||
|
.replaceAll('http://', '')
|
||||||
|
.replaceAll('www.', ''));
|
||||||
|
},
|
||||||
|
onTapOutside: (PointerDownEvent event) {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Website',
|
||||||
|
),
|
||||||
|
validator: (value) {
|
||||||
|
if (value != null && value.isEmpty) {
|
||||||
|
return 'Website is required';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 8.0, right: 8.0),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: _descriptionController,
|
controller: _descriptionController,
|
||||||
|
autovalidateMode:
|
||||||
|
AutovalidateMode.onUserInteraction,
|
||||||
maxLength: 500,
|
maxLength: 500,
|
||||||
maxLines: null,
|
|
||||||
onChanged: (inputDesc) {
|
onChanged: (inputDesc) {
|
||||||
setState(() {
|
setState(() {
|
||||||
business.description = inputDesc;
|
business.description = inputDesc;
|
||||||
@ -207,211 +236,104 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText:
|
labelText: 'Business Description',
|
||||||
'Business Description (required)',
|
|
||||||
),
|
),
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value != null && value.trim().isEmpty) {
|
if (value != null && value.isEmpty) {
|
||||||
return 'Description is required';
|
return 'Description is required';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.only(
|
||||||
|
// left: 8.0, right: 8.0, bottom: 16.0),
|
||||||
|
// child: Row(
|
||||||
|
// children: [
|
||||||
|
// ElevatedButton(
|
||||||
|
// style: ButtonStyle(
|
||||||
|
// backgroundColor:
|
||||||
|
// MaterialStateProperty.all(
|
||||||
|
// Theme.of(context)
|
||||||
|
// .colorScheme
|
||||||
|
// .background)),
|
||||||
|
// child: const Row(
|
||||||
|
// children: [
|
||||||
|
// Icon(Icons.search),
|
||||||
|
// Text('Search For Location'),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// onPressed: () {},
|
||||||
|
// ),
|
||||||
|
// const Padding(
|
||||||
|
// padding: EdgeInsets.only(
|
||||||
|
// left: 32.0, right: 32.0),
|
||||||
|
// child: Text(
|
||||||
|
// 'OR',
|
||||||
|
// style: TextStyle(fontSize: 24),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Expanded(
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// TextFormField(
|
||||||
|
// controller: _locationNameController,
|
||||||
|
// onChanged: (inputName) {
|
||||||
|
// setState(() {
|
||||||
|
// business.locationName =
|
||||||
|
// inputName;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// onTapOutside:
|
||||||
|
// (PointerDownEvent event) {
|
||||||
|
// FocusScope.of(context).unfocus();
|
||||||
|
// },
|
||||||
|
// decoration: const InputDecoration(
|
||||||
|
// labelText:
|
||||||
|
// 'Location Name (optional)',
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// TextFormField(
|
||||||
|
// controller:
|
||||||
|
// _locationAddressController,
|
||||||
|
// onChanged: (inputAddr) {
|
||||||
|
// setState(() {
|
||||||
|
// business.locationAddress =
|
||||||
|
// inputAddr;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// onTapOutside:
|
||||||
|
// (PointerDownEvent event) {
|
||||||
|
// FocusScope.of(context).unfocus();
|
||||||
|
// },
|
||||||
|
// decoration: const InputDecoration(
|
||||||
|
// labelText:
|
||||||
|
// 'Location Address (optional)',
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 8.0, right: 8.0, bottom: 16.0),
|
left: 8.0, right: 8.0, bottom: 8.0),
|
||||||
child: TextFormField(
|
|
||||||
controller: _websiteController,
|
|
||||||
keyboardType: TextInputType.url,
|
|
||||||
onChanged: (inputUrl) {
|
|
||||||
setState(() {
|
|
||||||
business.website =
|
|
||||||
Uri.encodeFull(inputUrl);
|
|
||||||
});
|
|
||||||
if (inputUrl.trim().isEmpty) {
|
|
||||||
business.website = null;
|
|
||||||
} else {
|
|
||||||
if (!business.website!
|
|
||||||
.contains('http://') &&
|
|
||||||
!business.website!
|
|
||||||
.contains('https://')) {
|
|
||||||
setState(() {
|
|
||||||
business.website =
|
|
||||||
'https://${business.website!.trim()}';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTapOutside: (PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Website',
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value != null &&
|
|
||||||
value.isNotEmpty &&
|
|
||||||
!RegExp(r'(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?:/[^/\s]*)*')
|
|
||||||
.hasMatch(value)) {
|
|
||||||
return 'Enter a valid Website';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0, right: 8.0, bottom: 16.0),
|
|
||||||
child: DropdownMenu<BusinessType>(
|
|
||||||
initialSelection: business.type,
|
|
||||||
width: (MediaQuery.sizeOf(context).width -
|
|
||||||
24) <
|
|
||||||
776
|
|
||||||
? MediaQuery.sizeOf(context).width - 24
|
|
||||||
: 776,
|
|
||||||
menuHeight: 300,
|
|
||||||
label: const Text('Business Type'),
|
|
||||||
errorText: dropDownErrorText,
|
|
||||||
dropdownMenuEntries: [
|
|
||||||
for (BusinessType type
|
|
||||||
in BusinessType.values)
|
|
||||||
DropdownMenuEntry(
|
|
||||||
value: type,
|
|
||||||
label:
|
|
||||||
getNameFromBusinessType(type)),
|
|
||||||
],
|
|
||||||
onSelected: (inputType) {
|
|
||||||
setState(() {
|
|
||||||
business.type = inputType!;
|
|
||||||
dropDownErrorText = null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0, right: 8.0, bottom: 16.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _contactNameController,
|
|
||||||
onSaved: (inputText) {
|
|
||||||
business.contactName = inputText!;
|
|
||||||
},
|
|
||||||
onTapOutside: (PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText:
|
|
||||||
'Contact Information Name (required)',
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.trim().isEmpty) {
|
|
||||||
return 'Contact name is required';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0, right: 8.0, bottom: 16.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _contactPhoneController,
|
|
||||||
inputFormatters: [PhoneFormatter()],
|
|
||||||
keyboardType: TextInputType.phone,
|
|
||||||
onChanged: (inputText) {
|
|
||||||
if (inputText.trim().isEmpty) {
|
|
||||||
business.contactPhone = null;
|
|
||||||
} else {
|
|
||||||
business.contactPhone = inputText.trim();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTapOutside: (PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Contact Phone #',
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (business.contactEmail == null &&
|
|
||||||
(value == null || value.isEmpty)) {
|
|
||||||
return 'At least one contact method is required';
|
|
||||||
}
|
|
||||||
if (value != null &&
|
|
||||||
value.isNotEmpty &&
|
|
||||||
value.length != 14) {
|
|
||||||
return 'Enter a valid phone number';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0, right: 8.0, bottom: 16.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _contactEmailController,
|
|
||||||
keyboardType: TextInputType.emailAddress,
|
|
||||||
onChanged: (inputText) {
|
|
||||||
if (inputText.trim().isEmpty) {
|
|
||||||
business.contactEmail = null;
|
|
||||||
} else {
|
|
||||||
business.contactEmail = inputText.trim();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTapOutside: (PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Contact Email',
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
value = value?.trim();
|
|
||||||
if (value != null && value.isEmpty) {
|
|
||||||
value = null;
|
|
||||||
}
|
|
||||||
if (value == null &&
|
|
||||||
business.contactPhone == null) {
|
|
||||||
return 'At least one contact method is required';
|
|
||||||
}
|
|
||||||
if (value != null) {
|
|
||||||
if (!RegExp(
|
|
||||||
r'^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')
|
|
||||||
.hasMatch(value)) {
|
|
||||||
return 'Enter a valid Email';
|
|
||||||
} else if (value.characters.length > 50) {
|
|
||||||
return 'Contact Email cannot be longer than 50 characters';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0, right: 8.0, bottom: 16.0),
|
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: _locationNameController,
|
controller: _locationNameController,
|
||||||
onChanged: (inputName) {
|
onChanged: (inputName) {
|
||||||
setState(() {
|
setState(() {
|
||||||
business.locationName = inputName.trim();
|
business.locationName = inputName;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onTapOutside: (PointerDownEvent event) {
|
onTapOutside: (PointerDownEvent event) {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Location Name (required)',
|
labelText: 'Location Name (optional)',
|
||||||
),
|
),
|
||||||
validator: (value) {
|
|
||||||
if (value != null && value.trim().isEmpty) {
|
|
||||||
return 'Location name is required';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
@ -428,11 +350,108 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Location Address (required)',
|
labelText: 'Location Address (optional)',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 8.0, right: 8.0, bottom: 8.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text('Type of Business',
|
||||||
|
style: TextStyle(fontSize: 16)),
|
||||||
|
DropdownMenu<BusinessType>(
|
||||||
|
initialSelection: business.type,
|
||||||
|
controller: businessTypeController,
|
||||||
|
label: const Text('Business Type'),
|
||||||
|
dropdownMenuEntries: const [
|
||||||
|
DropdownMenuEntry(
|
||||||
|
value: BusinessType.food,
|
||||||
|
label: 'Food Related'),
|
||||||
|
DropdownMenuEntry(
|
||||||
|
value: BusinessType.shop,
|
||||||
|
label: 'Shop'),
|
||||||
|
DropdownMenuEntry(
|
||||||
|
value: BusinessType.outdoors,
|
||||||
|
label: 'Outdoors'),
|
||||||
|
DropdownMenuEntry(
|
||||||
|
value: BusinessType.manufacturing,
|
||||||
|
label: 'Manufacturing'),
|
||||||
|
DropdownMenuEntry(
|
||||||
|
value: BusinessType.other,
|
||||||
|
label: 'Other'),
|
||||||
|
],
|
||||||
|
onSelected: (inputType) {
|
||||||
|
business.type = inputType!;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 8.0, right: 8.0, bottom: 8.0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _contactNameController,
|
||||||
|
onSaved: (inputText) {
|
||||||
|
business.contactName = inputText!;
|
||||||
|
},
|
||||||
|
onTapOutside: (PointerDownEvent event) {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText:
|
||||||
|
'Contact Information Name (optional)',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 8.0, right: 8.0, bottom: 8.0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _contactPhoneController,
|
||||||
|
inputFormatters: [PhoneFormatter()],
|
||||||
|
keyboardType: TextInputType.phone,
|
||||||
|
onSaved: (inputText) {
|
||||||
|
business.contactPhone = inputText!;
|
||||||
|
},
|
||||||
|
onTapOutside: (PointerDownEvent event) {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Contact Phone # (optional)',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 8.0, right: 8.0, bottom: 8.0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: _contactEmailController,
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
onSaved: (inputText) {
|
||||||
|
business.contactEmail = inputText!;
|
||||||
|
},
|
||||||
|
onTapOutside: (PointerDownEvent event) {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Contact Email (optional)',
|
||||||
),
|
),
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value != null && value.trim().isEmpty) {
|
if (value != null) {
|
||||||
return 'Location Address is required';
|
if (value.isEmpty) {
|
||||||
|
return null;
|
||||||
|
} else if (!RegExp(
|
||||||
|
r'^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$')
|
||||||
|
.hasMatch(value)) {
|
||||||
|
return 'Enter a valid Email';
|
||||||
|
} else if (value.characters.length > 50) {
|
||||||
|
return 'Contact Email cannot be longer than 50 characters';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -444,75 +463,23 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: _notesController,
|
controller: _notesController,
|
||||||
maxLength: 300,
|
maxLength: 300,
|
||||||
maxLines: null,
|
|
||||||
onSaved: (inputText) {
|
onSaved: (inputText) {
|
||||||
if (inputText == null ||
|
business.notes = inputText!;
|
||||||
inputText.trim().isEmpty) {
|
|
||||||
business.notes = null;
|
|
||||||
} else {
|
|
||||||
business.notes = inputText.trim();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onTapOutside: (PointerDownEvent event) {
|
onTapOutside: (PointerDownEvent event) {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Other Notes',
|
labelText: 'Other Notes (optional)',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!widescreen)
|
SizedBox(
|
||||||
const SizedBox(
|
|
||||||
height: 75,
|
height: 75,
|
||||||
)
|
)
|
||||||
else
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.topRight,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: FilledButton(
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 8.0, right: 8.0, bottom: 8.0),
|
|
||||||
child: _isLoading
|
|
||||||
? SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onPrimary,
|
|
||||||
strokeWidth: 3.0,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const Icon(Icons.save),
|
|
||||||
),
|
|
||||||
const Text('Save'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
if (!_isLoading) {
|
|
||||||
await _saveBusiness(context);
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
width: 400,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
content:
|
|
||||||
Text('Please wait for it to save.'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -534,53 +501,6 @@ class _CreateEditBusinessState extends State<CreateEditBusiness> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _saveBusiness(BuildContext context) async {
|
|
||||||
if (business.type == null) {
|
|
||||||
setState(() {
|
|
||||||
dropDownErrorText = 'Business type is required';
|
|
||||||
});
|
|
||||||
formKey.currentState!.validate();
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
dropDownErrorText = null;
|
|
||||||
});
|
|
||||||
if (formKey.currentState!.validate()) {
|
|
||||||
formKey.currentState?.save();
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
String? result;
|
|
||||||
if (widget.inputBusiness != null) {
|
|
||||||
result = await editBusiness(business);
|
|
||||||
} else {
|
|
||||||
result = await createBusiness(business);
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
if (result != null) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
width: 400,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
content: Text(result)));
|
|
||||||
} else {
|
|
||||||
Navigator.pushReplacement(context,
|
|
||||||
MaterialPageRoute(builder: (context) => const MainApp()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: const Text('Check field inputs!'),
|
|
||||||
width: 200,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
shape:
|
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PhoneFormatter extends TextInputFormatter {
|
class PhoneFormatter extends TextInputFormatter {
|
||||||
|
|||||||
@ -1,634 +0,0 @@
|
|||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:rive/rive.dart';
|
|
||||||
|
|
||||||
import '../main.dart';
|
|
||||||
|
|
||||||
class CreateEditJobListing extends StatefulWidget {
|
|
||||||
final JobListing? inputJobListing;
|
|
||||||
final Business? inputBusiness;
|
|
||||||
|
|
||||||
const CreateEditJobListing(
|
|
||||||
{super.key, this.inputJobListing, this.inputBusiness});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CreateEditJobListing> createState() => _CreateEditJobListingState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CreateEditJobListingState extends State<CreateEditJobListing> {
|
|
||||||
late Future getBusinessNameMapping;
|
|
||||||
late TextEditingController _nameController;
|
|
||||||
late TextEditingController _descriptionController;
|
|
||||||
late TextEditingController _wageController;
|
|
||||||
late TextEditingController _linkController;
|
|
||||||
List<Map<String, dynamic>> nameMapping = [];
|
|
||||||
String? typeDropdownErrorText;
|
|
||||||
String? businessDropdownErrorText;
|
|
||||||
late bool widescreen;
|
|
||||||
|
|
||||||
JobListing listing = JobListing(
|
|
||||||
id: null,
|
|
||||||
businessId: null,
|
|
||||||
name: 'Job Listing',
|
|
||||||
description: 'Add details about the job below.',
|
|
||||||
type: null,
|
|
||||||
wage: null,
|
|
||||||
link: null,
|
|
||||||
offerType: null);
|
|
||||||
bool _isLoading = false;
|
|
||||||
late String businessName;
|
|
||||||
bool _isRetrying = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
if (widget.inputJobListing != null) {
|
|
||||||
listing = JobListing.copy(widget.inputJobListing!);
|
|
||||||
_nameController = TextEditingController(text: listing.name);
|
|
||||||
_descriptionController = TextEditingController(text: listing.description);
|
|
||||||
} else {
|
|
||||||
_nameController = TextEditingController();
|
|
||||||
_descriptionController = TextEditingController();
|
|
||||||
}
|
|
||||||
_wageController = TextEditingController(text: listing.wage);
|
|
||||||
_linkController = TextEditingController(
|
|
||||||
text: listing.link
|
|
||||||
?.replaceAll('https://', '')
|
|
||||||
.replaceAll('http://', '')
|
|
||||||
.replaceAll('www.', ''));
|
|
||||||
getBusinessNameMapping = fetchBusinessNames();
|
|
||||||
businessName = widget.inputBusiness?.name ?? 'Offering business';
|
|
||||||
if (widget.inputBusiness != null) {
|
|
||||||
listing.businessId = widget.inputBusiness!.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final formKey = GlobalKey<FormState>();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
widescreen = MediaQuery.sizeOf(context).width >= widescreenWidth;
|
|
||||||
return PopScope(
|
|
||||||
canPop: !_isLoading,
|
|
||||||
onPopInvoked: _handlePop,
|
|
||||||
child: Form(
|
|
||||||
key: formKey,
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: (widget.inputJobListing != null)
|
|
||||||
? Text('Edit ${widget.inputJobListing?.name}', maxLines: 1)
|
|
||||||
: const Text('Add New Job Listing'),
|
|
||||||
),
|
|
||||||
floatingActionButton: !widescreen
|
|
||||||
? FloatingActionButton.extended(
|
|
||||||
heroTag: 'saveListing',
|
|
||||||
label: const Text('Save'),
|
|
||||||
icon: _isLoading
|
|
||||||
? const SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Colors.white,
|
|
||||||
strokeWidth: 3.0,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const Icon(Icons.save),
|
|
||||||
onPressed: () async {
|
|
||||||
if (!_isLoading) {
|
|
||||||
await _saveListing(context);
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
width: 400,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
content: Text('Please wait for it to save.'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
: null,
|
|
||||||
body: FutureBuilder(
|
|
||||||
future: getBusinessNameMapping,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
if (snapshot.data.runtimeType == String) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(children: [
|
|
||||||
Center(
|
|
||||||
child: Text(snapshot.data,
|
|
||||||
textAlign: TextAlign.center)),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: FilledButton(
|
|
||||||
child: const Text('Retry'),
|
|
||||||
onPressed: () async {
|
|
||||||
if (!_isRetrying) {
|
|
||||||
setState(() {
|
|
||||||
_isRetrying = true;
|
|
||||||
});
|
|
||||||
var refreshedData = fetchBusinessNames();
|
|
||||||
await refreshedData;
|
|
||||||
setState(() {
|
|
||||||
getBusinessNameMapping = refreshedData;
|
|
||||||
_isRetrying = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
nameMapping = snapshot.data;
|
|
||||||
nameMapping.sort((a, b) =>
|
|
||||||
a['name'].toString().compareTo(b['name'].toString()));
|
|
||||||
|
|
||||||
return ListView(
|
|
||||||
children: [
|
|
||||||
Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: 800,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 4.0),
|
|
||||||
child: Card(
|
|
||||||
child: Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.only(right: 8.0),
|
|
||||||
child: ListTile(
|
|
||||||
titleAlignment: ListTileTitleAlignment
|
|
||||||
.titleHeight,
|
|
||||||
title: Text(listing.name,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.bold)),
|
|
||||||
subtitle: Column(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
businessName,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
listing.description,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.only(left: 16),
|
|
||||||
leading: ClipRRect(
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(6.0),
|
|
||||||
child: Image.network(
|
|
||||||
'$apiAddress/logos/${listing.businessId}',
|
|
||||||
width: 48,
|
|
||||||
height: 48, errorBuilder:
|
|
||||||
(BuildContext context,
|
|
||||||
Object exception,
|
|
||||||
StackTrace?
|
|
||||||
stackTrace) {
|
|
||||||
return Icon(
|
|
||||||
getIconFromJobType(
|
|
||||||
listing.type ??
|
|
||||||
JobType.other),
|
|
||||||
size: 48);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Business Type Dropdown
|
|
||||||
Card(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 8.0,
|
|
||||||
top: 8.0),
|
|
||||||
child: DropdownMenu<int>(
|
|
||||||
menuHeight: 300,
|
|
||||||
width: (MediaQuery.sizeOf(context)
|
|
||||||
.width -
|
|
||||||
24) <
|
|
||||||
776
|
|
||||||
? MediaQuery.sizeOf(context)
|
|
||||||
.width -
|
|
||||||
24
|
|
||||||
: 776,
|
|
||||||
errorText:
|
|
||||||
businessDropdownErrorText,
|
|
||||||
initialSelection:
|
|
||||||
widget.inputBusiness?.id,
|
|
||||||
label: const Text(
|
|
||||||
'Offering Business'),
|
|
||||||
dropdownMenuEntries: [
|
|
||||||
for (Map<String, dynamic> map
|
|
||||||
in nameMapping)
|
|
||||||
DropdownMenuEntry(
|
|
||||||
value: map['id']!,
|
|
||||||
label: map['name'])
|
|
||||||
],
|
|
||||||
onSelected: (inputType) {
|
|
||||||
setState(() {
|
|
||||||
listing.businessId =
|
|
||||||
inputType!;
|
|
||||||
businessName = nameMapping
|
|
||||||
.where((element) =>
|
|
||||||
element['id'] ==
|
|
||||||
listing.businessId)
|
|
||||||
.first['name'];
|
|
||||||
businessDropdownErrorText =
|
|
||||||
null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Wrap(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 16.0,
|
|
||||||
top: 8.0),
|
|
||||||
child: DropdownMenu<JobType>(
|
|
||||||
initialSelection:
|
|
||||||
listing.type,
|
|
||||||
label: const Text('Job Type'),
|
|
||||||
errorText:
|
|
||||||
typeDropdownErrorText,
|
|
||||||
width: calculateDropdownWidth(
|
|
||||||
context),
|
|
||||||
menuHeight: 300,
|
|
||||||
dropdownMenuEntries: [
|
|
||||||
for (JobType type
|
|
||||||
in JobType.values)
|
|
||||||
DropdownMenuEntry(
|
|
||||||
value: type,
|
|
||||||
label:
|
|
||||||
getNameFromJobType(
|
|
||||||
type))
|
|
||||||
],
|
|
||||||
onSelected: (inputType) {
|
|
||||||
setState(() {
|
|
||||||
listing.type = inputType!;
|
|
||||||
typeDropdownErrorText =
|
|
||||||
null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 8.0,
|
|
||||||
top: 8.0),
|
|
||||||
child: DropdownMenu<OfferType>(
|
|
||||||
initialSelection:
|
|
||||||
listing.offerType,
|
|
||||||
label:
|
|
||||||
const Text('Offer Type'),
|
|
||||||
errorText:
|
|
||||||
typeDropdownErrorText,
|
|
||||||
width: calculateDropdownWidth(
|
|
||||||
context),
|
|
||||||
dropdownMenuEntries: [
|
|
||||||
for (OfferType type
|
|
||||||
in OfferType.values)
|
|
||||||
DropdownMenuEntry(
|
|
||||||
value: type,
|
|
||||||
label:
|
|
||||||
getNameFromOfferType(
|
|
||||||
type))
|
|
||||||
],
|
|
||||||
onSelected: (inputType) {
|
|
||||||
setState(() {
|
|
||||||
listing.offerType =
|
|
||||||
inputType!;
|
|
||||||
typeDropdownErrorText =
|
|
||||||
null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 8.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _nameController,
|
|
||||||
maxLength: 40,
|
|
||||||
onChanged: (inputName) {
|
|
||||||
setState(() {
|
|
||||||
listing.name = inputName;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onTapOutside:
|
|
||||||
(PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText:
|
|
||||||
'Job Listing Name (required)',
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value != null &&
|
|
||||||
value.isEmpty) {
|
|
||||||
return 'Name is required';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 8.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _descriptionController,
|
|
||||||
maxLength: 500,
|
|
||||||
maxLines: null,
|
|
||||||
onChanged: (inputDesc) {
|
|
||||||
setState(() {
|
|
||||||
listing.description = inputDesc;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onTapOutside:
|
|
||||||
(PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText:
|
|
||||||
'Job Listing Description (required)',
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value != null &&
|
|
||||||
value.isEmpty) {
|
|
||||||
return 'Description is required';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 16.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _wageController,
|
|
||||||
onChanged: (input) {
|
|
||||||
setState(() {
|
|
||||||
listing.wage = input;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onTapOutside:
|
|
||||||
(PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Wage Information',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 16.0),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _linkController,
|
|
||||||
keyboardType: TextInputType.url,
|
|
||||||
onChanged: (inputUrl) {
|
|
||||||
if (inputUrl != '') {
|
|
||||||
listing.link =
|
|
||||||
Uri.encodeFull(inputUrl);
|
|
||||||
if (!listing.link!
|
|
||||||
.contains('http://') &&
|
|
||||||
!listing.link!
|
|
||||||
.contains('https://')) {
|
|
||||||
listing.link =
|
|
||||||
'https://${listing.link}';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
listing.link = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
validator: (value) {
|
|
||||||
if (value != null &&
|
|
||||||
value.isNotEmpty &&
|
|
||||||
!RegExp(r'(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?:/[^/\s]*)*')
|
|
||||||
.hasMatch(value)) {
|
|
||||||
return 'Enter a valid Website';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onTapOutside:
|
|
||||||
(PointerDownEvent event) {
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText:
|
|
||||||
'Additional Information Link',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!widescreen)
|
|
||||||
const SizedBox(
|
|
||||||
height: 75,
|
|
||||||
)
|
|
||||||
else
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.topRight,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: FilledButton(
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 8.0,
|
|
||||||
right: 8.0,
|
|
||||||
bottom: 8.0),
|
|
||||||
child: _isLoading
|
|
||||||
? SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child:
|
|
||||||
CircularProgressIndicator(
|
|
||||||
color:
|
|
||||||
Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onPrimary,
|
|
||||||
strokeWidth: 3.0,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const Icon(Icons.save),
|
|
||||||
),
|
|
||||||
const Text('Save'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
if (!_isLoading) {
|
|
||||||
await _saveListing(context);
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
width: 400,
|
|
||||||
behavior:
|
|
||||||
SnackBarBehavior.floating,
|
|
||||||
content: Text(
|
|
||||||
'Please wait for it to save.'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
} else if (snapshot.hasError) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
|
||||||
child: Text(
|
|
||||||
'Error when loading data! Error: ${snapshot.error}'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (snapshot.connectionState ==
|
|
||||||
ConnectionState.waiting) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: const SizedBox(
|
|
||||||
width: 75,
|
|
||||||
height: 75,
|
|
||||||
child: RiveAnimation.asset(
|
|
||||||
'assets/mdev_triangle_loading.riv'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.only(left: 16.0, right: 16.0),
|
|
||||||
child: Text('Error when loading data!'),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
double calculateDropdownWidth(BuildContext context) {
|
|
||||||
double screenWidth = MediaQuery.sizeOf(context).width;
|
|
||||||
|
|
||||||
if ((screenWidth - 40) / 2 < 200) {
|
|
||||||
return screenWidth - 24;
|
|
||||||
} else if ((screenWidth - 40) / 2 < 380) {
|
|
||||||
return (screenWidth - 40) / 2;
|
|
||||||
} else {
|
|
||||||
return 380;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handlePop(bool didPop) {
|
|
||||||
if (!didPop) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
width: 400,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
content: Text('Please wait for it to save.'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _saveListing(BuildContext context) async {
|
|
||||||
if (listing.type == null || listing.businessId == null) {
|
|
||||||
if (listing.type == null) {
|
|
||||||
setState(() {
|
|
||||||
typeDropdownErrorText = 'Job type is required';
|
|
||||||
});
|
|
||||||
formKey.currentState!.validate();
|
|
||||||
}
|
|
||||||
if (listing.businessId == null) {
|
|
||||||
setState(() {
|
|
||||||
businessDropdownErrorText = 'Business is required';
|
|
||||||
});
|
|
||||||
formKey.currentState!.validate();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
typeDropdownErrorText = null;
|
|
||||||
businessDropdownErrorText = null;
|
|
||||||
});
|
|
||||||
if (formKey.currentState!.validate()) {
|
|
||||||
formKey.currentState?.save();
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
String? result;
|
|
||||||
if (widget.inputJobListing != null) {
|
|
||||||
result = await editListing(listing);
|
|
||||||
} else {
|
|
||||||
result = await createListing(listing);
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
if (result != null) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
width: 400,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
content: Text(result)));
|
|
||||||
} else {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const MainApp(
|
|
||||||
initialPage: 1,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: const Text('Check field inputs!'),
|
|
||||||
width: 200,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
shape:
|
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
574
fbla_ui/lib/pages/export_data.dart
Normal file
574
fbla_ui/lib/pages/export_data.dart
Normal file
@ -0,0 +1,574 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fbla_ui/api_logic.dart';
|
||||||
|
import 'package:fbla_ui/shared.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:open_filex/open_filex.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:pdf/pdf.dart';
|
||||||
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
|
import 'package:printing/printing.dart';
|
||||||
|
|
||||||
|
bool isDataTypesFiltered = false;
|
||||||
|
bool isBusinessesFiltered = true;
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
class ExportData extends StatefulWidget {
|
||||||
|
final List<Business> businesses;
|
||||||
|
|
||||||
|
const ExportData({super.key, required this.businesses});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ExportData> createState() => _ExportDataState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ExportDataState extends State<ExportData> {
|
||||||
|
late Future refreshBusinessDataFuture;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
refreshBusinessDataFuture = fetchBusinessData();
|
||||||
|
_isLoading = false;
|
||||||
|
selectedBusinesses = <Business>{};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
floatingActionButton: _FAB(businesses: widget.businesses),
|
||||||
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverAppBar(
|
||||||
|
forceMaterialTransparency: false,
|
||||||
|
title: const Text('Export Data'),
|
||||||
|
toolbarHeight: 70,
|
||||||
|
pinned: true,
|
||||||
|
centerTitle: true,
|
||||||
|
expandedHeight: 120,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.background,
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.settings),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
// DO NOT MOVE TO SEPARATE WIDGET, setState is needed in main tree
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.background,
|
||||||
|
title: const Text('Data Types'),
|
||||||
|
content: const SizedBox(
|
||||||
|
width: 400,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Data Columns you would like to show on the datasheet'),
|
||||||
|
FilterDataTypeChips(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Reset'),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
dataTypeFilters = <DataType>{};
|
||||||
|
selectedDataTypes = <DataType>{};
|
||||||
|
isDataTypesFiltered = false;
|
||||||
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
onPressed: () {
|
||||||
|
selectedDataTypes = Set.from(dataTypeFilters);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Apply'),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
selectedDataTypes =
|
||||||
|
sortDataTypes(selectedDataTypes);
|
||||||
|
dataTypeFilters =
|
||||||
|
Set.from(selectedDataTypes);
|
||||||
|
if (dataTypeFilters.isNotEmpty) {
|
||||||
|
isDataTypesFiltered = true;
|
||||||
|
} else {
|
||||||
|
isDataTypesFiltered = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
bottom: PreferredSize(
|
||||||
|
preferredSize: const Size.fromHeight(0),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 70,
|
||||||
|
width: 1000,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: TextField(
|
||||||
|
onChanged: (query) {
|
||||||
|
setState(() {
|
||||||
|
searchFilter = query;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Search',
|
||||||
|
hintText: 'Search',
|
||||||
|
prefixIcon: const Padding(
|
||||||
|
padding: EdgeInsets.only(left: 8.0),
|
||||||
|
child: Icon(Icons.search),
|
||||||
|
),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||||
|
),
|
||||||
|
suffixIcon: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(Icons.filter_list,
|
||||||
|
color: isFiltered
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onBackground),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
// DO NOT MOVE TO SEPARATE WIDGET, setState is needed in main tree
|
||||||
|
backgroundColor: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.background,
|
||||||
|
title: const Text('Filter Options'),
|
||||||
|
content: const FilterChips(),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Reset'),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
filters = <BusinessType>{};
|
||||||
|
selectedChips = <BusinessType>{};
|
||||||
|
isFiltered = false;
|
||||||
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
onPressed: () {
|
||||||
|
selectedChips = Set.from(filters);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Apply'),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
filters = selectedChips;
|
||||||
|
if (filters.isNotEmpty) {
|
||||||
|
isFiltered = true;
|
||||||
|
} else {
|
||||||
|
isFiltered = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
BusinessDisplayPanel(
|
||||||
|
businesses: widget.businesses,
|
||||||
|
widescreen: MediaQuery.sizeOf(context).width >= 1000,
|
||||||
|
selectable: true),
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 100,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FAB extends StatefulWidget {
|
||||||
|
final List<Business> businesses;
|
||||||
|
|
||||||
|
const _FAB({required this.businesses});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_FAB> createState() => _FABState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FABState extends State<_FAB> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FloatingActionButton(
|
||||||
|
child: _isLoading
|
||||||
|
? const Padding(
|
||||||
|
padding: EdgeInsets.all(16.0),
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.white,
|
||||||
|
strokeWidth: 3.0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.save_alt),
|
||||||
|
onPressed: () async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
DateTime dateTime = DateTime.now();
|
||||||
|
String minute = '00';
|
||||||
|
if (dateTime.minute.toString().length < 2) {
|
||||||
|
minute = '0${dateTime.minute}';
|
||||||
|
} else {
|
||||||
|
minute = dateTime.minute.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
String time = dateTime.hour <= 13
|
||||||
|
? '${dateTime.hour}:${minute}AM'
|
||||||
|
: '${dateTime.hour - 12}:${minute}PM';
|
||||||
|
String fileName =
|
||||||
|
'Business Data - ${dateTime.month}-${dateTime.day}-${dateTime.year} $time.pdf';
|
||||||
|
|
||||||
|
final pdf = pw.Document();
|
||||||
|
var svgBytes = await marinoDevLogo();
|
||||||
|
selectedDataTypes = sortDataTypes(selectedDataTypes);
|
||||||
|
|
||||||
|
List<pw.Padding> headers = [];
|
||||||
|
if (selectedDataTypes.isEmpty) {
|
||||||
|
dataTypeFilters.addAll(DataType.values);
|
||||||
|
} else {
|
||||||
|
for (var filter in selectedDataTypes) {
|
||||||
|
dataTypeFilters.add(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var filter in dataTypeFilters) {
|
||||||
|
headers.add(pw.Padding(
|
||||||
|
child: pw.Text(dataTypeFriendly[filter]!,
|
||||||
|
style: const pw.TextStyle(fontSize: 10)),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<pw.TableRow> rows = [];
|
||||||
|
if (selectedBusinesses.isEmpty) {
|
||||||
|
selectedBusinesses.addAll(widget.businesses);
|
||||||
|
isBusinessesFiltered = false;
|
||||||
|
} else {
|
||||||
|
isBusinessesFiltered = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
double remainingSpace = 744;
|
||||||
|
|
||||||
|
if (dataTypeFilters.contains(DataType.logo)) {
|
||||||
|
remainingSpace -= 32;
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.type)) {
|
||||||
|
remainingSpace -= 56;
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.contactName)) {
|
||||||
|
remainingSpace -= 72;
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.contactPhone)) {
|
||||||
|
remainingSpace -= 76;
|
||||||
|
}
|
||||||
|
|
||||||
|
double nameWidth = 0;
|
||||||
|
double websiteWidth = 0;
|
||||||
|
double contactEmailWidth = 0;
|
||||||
|
double notesWidth = 0;
|
||||||
|
double descriptionWidth = 0;
|
||||||
|
if (dataTypeFilters.contains(DataType.name)) {
|
||||||
|
nameWidth = (remainingSpace / 6);
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.website)) {
|
||||||
|
websiteWidth = (remainingSpace / 5);
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.contactEmail)) {
|
||||||
|
contactEmailWidth = (remainingSpace / 5);
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.notes)) {
|
||||||
|
notesWidth = (remainingSpace / 7);
|
||||||
|
}
|
||||||
|
remainingSpace -=
|
||||||
|
(nameWidth + websiteWidth + contactEmailWidth + notesWidth);
|
||||||
|
if (dataTypeFilters.contains(DataType.description)) {
|
||||||
|
descriptionWidth = remainingSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<int, pw.TableColumnWidth> columnWidths = {};
|
||||||
|
|
||||||
|
int columnNum = -1;
|
||||||
|
for (var dataType in dataTypeFilters) {
|
||||||
|
pw.TableColumnWidth width = const pw.FixedColumnWidth(0);
|
||||||
|
if (dataType == DataType.logo) {
|
||||||
|
width = const pw.FixedColumnWidth(32);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.name) {
|
||||||
|
width = pw.FixedColumnWidth(nameWidth);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.description) {
|
||||||
|
width = pw.FixedColumnWidth(descriptionWidth);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.type) {
|
||||||
|
width = const pw.FixedColumnWidth(56);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.website) {
|
||||||
|
width = pw.FixedColumnWidth(websiteWidth);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.contactName) {
|
||||||
|
width = const pw.FixedColumnWidth(72);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.contactEmail) {
|
||||||
|
width = pw.FixedColumnWidth(contactEmailWidth);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.contactPhone) {
|
||||||
|
width = const pw.FixedColumnWidth(76);
|
||||||
|
columnNum++;
|
||||||
|
} else if (dataType == DataType.notes) {
|
||||||
|
width = pw.FixedColumnWidth(notesWidth);
|
||||||
|
columnNum++;
|
||||||
|
}
|
||||||
|
|
||||||
|
columnWidths.addAll({columnNum: width});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var business in selectedBusinesses) {
|
||||||
|
List<pw.Padding> data = [];
|
||||||
|
bool hasLogo = false;
|
||||||
|
Uint8List businessLogo = Uint8List(0);
|
||||||
|
if (dataTypeFilters.contains(DataType.logo)) {
|
||||||
|
try {
|
||||||
|
var apiLogo = await getLogo(business.id);
|
||||||
|
if (apiLogo.runtimeType != String) {
|
||||||
|
businessLogo = apiLogo;
|
||||||
|
hasLogo = true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
print('Logo not available! $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.name)) {
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(
|
||||||
|
business.name,
|
||||||
|
// style: const pw.TextStyle(fontSize: 10)
|
||||||
|
),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.description)) {
|
||||||
|
pw.TextStyle style = const pw.TextStyle(fontSize: 9);
|
||||||
|
if (business.description.length >= 200) {
|
||||||
|
style = const pw.TextStyle(fontSize: 8);
|
||||||
|
}
|
||||||
|
if (business.description.length >= 400) {
|
||||||
|
style = const pw.TextStyle(fontSize: 7);
|
||||||
|
}
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(
|
||||||
|
business.description,
|
||||||
|
style: style,
|
||||||
|
),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.type)) {
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(
|
||||||
|
business.type.name,
|
||||||
|
// style: const pw.TextStyle(fontSize: 10)
|
||||||
|
),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.website)) {
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(
|
||||||
|
business.website,
|
||||||
|
// style: const pw.TextStyle(fontSize: 10)
|
||||||
|
),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.contactName)) {
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(
|
||||||
|
business.contactName,
|
||||||
|
// style: const pw.TextStyle(fontSize: 10)
|
||||||
|
),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.contactEmail)) {
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(
|
||||||
|
business.contactEmail,
|
||||||
|
// style: const pw.TextStyle(fontSize: 10)
|
||||||
|
),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.contactPhone)) {
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(
|
||||||
|
business.contactPhone,
|
||||||
|
// style: const pw.TextStyle(fontSize: 10)
|
||||||
|
),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
if (dataTypeFilters.contains(DataType.notes)) {
|
||||||
|
pw.TextStyle style = const pw.TextStyle(fontSize: 9);
|
||||||
|
if (business.description.length >= 200) {
|
||||||
|
style = const pw.TextStyle(fontSize: 8);
|
||||||
|
}
|
||||||
|
data.add(pw.Padding(
|
||||||
|
child: pw.Text(business.notes, style: style),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataTypeFilters.contains(DataType.logo)) {
|
||||||
|
if (hasLogo) {
|
||||||
|
rows.add(pw.TableRow(
|
||||||
|
children: [
|
||||||
|
pw.Padding(
|
||||||
|
child: pw.ClipRRect(
|
||||||
|
child: pw.Image(pw.MemoryImage(businessLogo),
|
||||||
|
height: 24, width: 24),
|
||||||
|
horizontalRadius: 4,
|
||||||
|
verticalRadius: 4),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)),
|
||||||
|
...data
|
||||||
|
],
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
rows.add(pw.TableRow(
|
||||||
|
children: [
|
||||||
|
pw.Padding(
|
||||||
|
child: getPwIconFromType(
|
||||||
|
business.type, 24, PdfColors.black),
|
||||||
|
padding: const pw.EdgeInsets.all(4.0)),
|
||||||
|
...data
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rows.add(pw.TableRow(
|
||||||
|
children: data,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var themeIcon = pw.ThemeData.withFont(
|
||||||
|
base: await PdfGoogleFonts.notoSansDisplayMedium(),
|
||||||
|
icons: await PdfGoogleFonts.materialIcons());
|
||||||
|
|
||||||
|
var finaltheme = themeIcon.copyWith(
|
||||||
|
defaultTextStyle: const pw.TextStyle(fontSize: 9),
|
||||||
|
);
|
||||||
|
pdf.addPage(pw.MultiPage(
|
||||||
|
theme: finaltheme,
|
||||||
|
// theme: pw.ThemeData(
|
||||||
|
// tableCell: const pw.TextStyle(fontSize: 4),
|
||||||
|
// defaultTextStyle: const pw.TextStyle(fontSize: 4),
|
||||||
|
// header0: const pw.TextStyle(fontSize: 4),
|
||||||
|
// paragraphStyle: const pw.TextStyle(fontSize: 4),
|
||||||
|
// ),
|
||||||
|
// theme: pw.ThemeData.withFont(
|
||||||
|
// icons: await PdfGoogleFonts.materialIcons()),
|
||||||
|
pageFormat: PdfPageFormat.letter,
|
||||||
|
orientation: pw.PageOrientation.landscape,
|
||||||
|
margin: const pw.EdgeInsets.all(24),
|
||||||
|
build: (pw.Context context) {
|
||||||
|
return [
|
||||||
|
pw.Row(
|
||||||
|
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
pw.SvgImage(svg: utf8.decode(svgBytes), height: 40),
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(8.0),
|
||||||
|
child: pw.Text('Business Datasheet',
|
||||||
|
style: pw.TextStyle(
|
||||||
|
fontSize: 32,
|
||||||
|
fontWeight: pw.FontWeight.bold)),
|
||||||
|
),
|
||||||
|
pw.Text(
|
||||||
|
'Generated on ${dateTime.month}/${dateTime.day}/${dateTime.year} at $time',
|
||||||
|
style: const pw.TextStyle(fontSize: 12),
|
||||||
|
textAlign: pw.TextAlign.right),
|
||||||
|
//
|
||||||
|
]),
|
||||||
|
pw.Table(
|
||||||
|
columnWidths: columnWidths,
|
||||||
|
// defaultColumnWidth: pw.IntrinsicColumnWidth(),
|
||||||
|
border: const pw.TableBorder(
|
||||||
|
bottom: pw.BorderSide(),
|
||||||
|
left: pw.BorderSide(),
|
||||||
|
right: pw.BorderSide(),
|
||||||
|
top: pw.BorderSide(),
|
||||||
|
horizontalInside: pw.BorderSide(),
|
||||||
|
verticalInside: pw.BorderSide()),
|
||||||
|
children: [
|
||||||
|
pw.TableRow(
|
||||||
|
decoration:
|
||||||
|
const pw.BoxDecoration(color: PdfColors.blue400),
|
||||||
|
children: headers,
|
||||||
|
repeat: true,
|
||||||
|
),
|
||||||
|
...rows,
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
}));
|
||||||
|
|
||||||
|
Uint8List pdfBytes = await pdf.save();
|
||||||
|
|
||||||
|
if (kIsWeb) {
|
||||||
|
await Printing.sharePdf(
|
||||||
|
bytes: await pdf.save(),
|
||||||
|
filename: fileName,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
var dir = await getTemporaryDirectory();
|
||||||
|
var tempDir = dir.path;
|
||||||
|
|
||||||
|
File pdfFile = File('$tempDir/$fileName');
|
||||||
|
pdfFile.writeAsBytesSync(pdfBytes);
|
||||||
|
|
||||||
|
OpenFilex.open(pdfFile.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isBusinessesFiltered) {
|
||||||
|
selectedBusinesses = <Business>{};
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
|
content: Text('Error generating PDF! $e'),
|
||||||
|
width: 300,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,212 +0,0 @@
|
|||||||
import 'package:fbla_ui/main.dart';
|
|
||||||
import 'package:fbla_ui/pages/business_detail.dart';
|
|
||||||
import 'package:fbla_ui/pages/create_edit_listing.dart';
|
|
||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:fbla_ui/shared/widgets.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
/// A page to view all specific details about a single job listing (with its businesses contact info)
|
|
||||||
class JobListingDetail extends StatefulWidget {
|
|
||||||
final JobListing listing;
|
|
||||||
final Business fromBusiness;
|
|
||||||
|
|
||||||
const JobListingDetail(
|
|
||||||
{super.key, required this.listing, required this.fromBusiness});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<JobListingDetail> createState() => _CreateBusinessDetailState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CreateBusinessDetailState extends State<JobListingDetail> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(widget.listing.name),
|
|
||||||
actions: _getActions(widget.listing, widget.fromBusiness),
|
|
||||||
),
|
|
||||||
body: _detailBody(widget.listing),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// body of the JobListingDetail
|
|
||||||
Widget _detailBody(JobListing listing) {
|
|
||||||
return ListView(
|
|
||||||
children: [
|
|
||||||
Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: 800,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
// Top summary card
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 4.0),
|
|
||||||
child: _summaryCard(listing)),
|
|
||||||
// Wage card
|
|
||||||
if (listing.wage != null && listing.wage != '')
|
|
||||||
Card(
|
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(Icons.attach_money),
|
|
||||||
subtitle: Text(listing.wage!),
|
|
||||||
title: const Text('Wage Information'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Contact information for the business contact
|
|
||||||
ContactInformationCard(business: widget.fromBusiness)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Top card including title, logo, description, and business name
|
|
||||||
Widget _summaryCard(JobListing listing) {
|
|
||||||
return Card(
|
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 8.0),
|
|
||||||
child: ListTile(
|
|
||||||
minVerticalPadding: 0,
|
|
||||||
titleAlignment: ListTileTitleAlignment.titleHeight,
|
|
||||||
title: Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
|
||||||
child: Text(
|
|
||||||
'${listing.name} (${getNameFromOfferType(listing.offerType!)})',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24, fontWeight: FontWeight.bold)),
|
|
||||||
),
|
|
||||||
subtitle: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(context,
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
return BusinessDetail(
|
|
||||||
id: widget.fromBusiness.id,
|
|
||||||
name: widget.fromBusiness.name!);
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
widget.fromBusiness.name!,
|
|
||||||
style: const TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(listing.description),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.only(bottom: 8, left: 16),
|
|
||||||
leading: Badge(
|
|
||||||
label: Text(
|
|
||||||
getLetterFromOfferType(listing.offerType!),
|
|
||||||
style: const TextStyle(fontSize: 16),
|
|
||||||
),
|
|
||||||
largeSize: 24,
|
|
||||||
offset: const Offset(12, -3),
|
|
||||||
textColor: Colors.white,
|
|
||||||
backgroundColor: getColorFromOfferType(listing.offerType!),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(6.0),
|
|
||||||
child: Image.network(
|
|
||||||
'$apiAddress/logos/${widget.fromBusiness.id}',
|
|
||||||
width: 48,
|
|
||||||
height: 48, errorBuilder: (BuildContext context,
|
|
||||||
Object exception, StackTrace? stackTrace) {
|
|
||||||
return Icon(
|
|
||||||
getIconFromJobType(listing.type ?? JobType.other),
|
|
||||||
size: 48);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (listing.link != null && listing.link != '')
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.link),
|
|
||||||
title: const Text('More Information'),
|
|
||||||
subtitle: Text(
|
|
||||||
listing.link!
|
|
||||||
.replaceAll('https://', '')
|
|
||||||
.replaceAll('http://', '')
|
|
||||||
.replaceAll('www.', ''),
|
|
||||||
style: const TextStyle(color: Colors.blue)),
|
|
||||||
onTap: () {
|
|
||||||
launchUrl(Uri.parse(listing.link!));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Edit / delete actions if the user is logged in
|
|
||||||
List<Widget>? _getActions(JobListing listing, Business fromBusiness) {
|
|
||||||
if (loggedIn) {
|
|
||||||
return [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.edit),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => CreateEditJobListing(
|
|
||||||
inputJobListing: listing,
|
|
||||||
inputBusiness: fromBusiness,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.delete),
|
|
||||||
onPressed: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
title: const Text('Are You Sure?'),
|
|
||||||
content:
|
|
||||||
Text('This will permanently delete ${listing.name}.'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Yes'),
|
|
||||||
onPressed: () async {
|
|
||||||
String? deleteResult =
|
|
||||||
await deleteListing(listing.id!);
|
|
||||||
if (deleteResult != null) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
width: 300,
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
content: Text(deleteResult)));
|
|
||||||
} else {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const MainApp(
|
|
||||||
initialPage: 1,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,696 +0,0 @@
|
|||||||
import 'package:fbla_ui/pages/create_edit_listing.dart';
|
|
||||||
import 'package:fbla_ui/pages/listing_detail.dart';
|
|
||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
|
||||||
import 'package:fbla_ui/shared/export.dart';
|
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:fbla_ui/shared/widgets.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
|
|
||||||
import 'package:rive/rive.dart';
|
|
||||||
import 'package:sliver_tools/sliver_tools.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
class JobsOverview extends StatefulWidget {
|
|
||||||
final String searchQuery;
|
|
||||||
final Future refreshJobDataOverviewFuture;
|
|
||||||
final Future<void> Function(Set<JobType>?, Set<OfferType>?)
|
|
||||||
updateBusinessesCallback;
|
|
||||||
final void Function() themeCallback;
|
|
||||||
final void Function(bool) updateLoggedIn;
|
|
||||||
|
|
||||||
const JobsOverview({
|
|
||||||
super.key,
|
|
||||||
required this.searchQuery,
|
|
||||||
required this.refreshJobDataOverviewFuture,
|
|
||||||
required this.updateBusinessesCallback,
|
|
||||||
required this.themeCallback,
|
|
||||||
required this.updateLoggedIn,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<JobsOverview> createState() => _JobsOverviewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _JobsOverviewState extends State<JobsOverview> {
|
|
||||||
bool _isPreviousData = false;
|
|
||||||
late Map<JobType, List<Business>> overviewBusinesses;
|
|
||||||
Set<JobType> jobTypeFilters = <JobType>{};
|
|
||||||
Set<OfferType> offerTypeFilters = <OfferType>{};
|
|
||||||
String searchQuery = '';
|
|
||||||
ScrollController controller = ScrollController();
|
|
||||||
bool _extended = true;
|
|
||||||
double prevPixelPosition = 0;
|
|
||||||
bool _isRetrying = false;
|
|
||||||
|
|
||||||
Map<JobType, List<Business>> _filterBySearch(
|
|
||||||
Map<JobType, List<Business>> businesses, String query) {
|
|
||||||
Map<JobType, List<Business>> filteredBusinesses = {};
|
|
||||||
|
|
||||||
for (JobType jobType in businesses.keys) {
|
|
||||||
filteredBusinesses[jobType] = List.from(businesses[jobType]!.where(
|
|
||||||
(element) => element.listings![0].name
|
|
||||||
.replaceAll(RegExp(r'[^a-zA-Z]'), '')
|
|
||||||
.toLowerCase()
|
|
||||||
.contains(query
|
|
||||||
.replaceAll(RegExp(r'[^a-zA-Z]'), '')
|
|
||||||
.toLowerCase()
|
|
||||||
.trim())));
|
|
||||||
}
|
|
||||||
|
|
||||||
filteredBusinesses.removeWhere((key, value) => value.isEmpty);
|
|
||||||
return filteredBusinesses;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _setSearch(String search) async {
|
|
||||||
setState(() {
|
|
||||||
searchQuery = search;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _setFilters(Set<JobType>? newJobTypeFilters,
|
|
||||||
Set<OfferType>? newOfferTypeFilters) async {
|
|
||||||
if (newJobTypeFilters != null) {
|
|
||||||
jobTypeFilters = Set.from(newJobTypeFilters);
|
|
||||||
}
|
|
||||||
if (newOfferTypeFilters != null) {
|
|
||||||
offerTypeFilters = Set.from(newOfferTypeFilters);
|
|
||||||
}
|
|
||||||
widget.updateBusinessesCallback(jobTypeFilters, offerTypeFilters);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _scrollListener() {
|
|
||||||
if ((prevPixelPosition - controller.position.pixels).abs() > 10) {
|
|
||||||
setState(() {
|
|
||||||
_extended =
|
|
||||||
controller.position.userScrollDirection == ScrollDirection.forward;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
prevPixelPosition = controller.position.pixels;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _generatePDF() {
|
|
||||||
List<Business> allJobs = [];
|
|
||||||
for (List<Business> businesses
|
|
||||||
in _filterBySearch(overviewBusinesses, searchQuery).values) {
|
|
||||||
allJobs.addAll(businesses);
|
|
||||||
}
|
|
||||||
|
|
||||||
generatePDF(
|
|
||||||
context: context,
|
|
||||||
documentTypeIndex: 1,
|
|
||||||
selectedJobs: Set.from(allJobs));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
controller.addListener(_scrollListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
bool widescreen = MediaQuery.sizeOf(context).width >= widescreenWidth;
|
|
||||||
return Scaffold(
|
|
||||||
floatingActionButton: _getFAB(widescreen),
|
|
||||||
body: CustomScrollView(
|
|
||||||
controller: controller,
|
|
||||||
slivers: [
|
|
||||||
MainSliverAppBar(
|
|
||||||
widescreen: widescreen,
|
|
||||||
setSearch: _setSearch,
|
|
||||||
searchHintText: 'Search Job Listings',
|
|
||||||
themeCallback: widget.themeCallback,
|
|
||||||
filterIconButton:
|
|
||||||
_filterIconButton(jobTypeFilters, offerTypeFilters),
|
|
||||||
updateLoggedIn: widget.updateLoggedIn,
|
|
||||||
generatePDF: _generatePDF,
|
|
||||||
),
|
|
||||||
FutureBuilder(
|
|
||||||
future: widget.refreshJobDataOverviewFuture,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
if (snapshot.data.runtimeType == String) {
|
|
||||||
_isPreviousData = false;
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(children: [
|
|
||||||
Center(
|
|
||||||
child: Text(snapshot.data,
|
|
||||||
textAlign: TextAlign.center)),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: FilledButton(
|
|
||||||
child: const Text('Retry'),
|
|
||||||
onPressed: () async {
|
|
||||||
if (!_isRetrying) {
|
|
||||||
setState(() {
|
|
||||||
_isRetrying = true;
|
|
||||||
});
|
|
||||||
await widget.updateBusinessesCallback(
|
|
||||||
null, null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
overviewBusinesses = snapshot.data;
|
|
||||||
_isPreviousData = true;
|
|
||||||
|
|
||||||
return JobDisplayPanel(
|
|
||||||
jobGroupedBusinesses:
|
|
||||||
_filterBySearch(overviewBusinesses, searchQuery),
|
|
||||||
widescreen: widescreen,
|
|
||||||
);
|
|
||||||
} else if (snapshot.hasError) {
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
|
||||||
child: Text(
|
|
||||||
'Error when loading data! Error: ${snapshot.error}'),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else if (snapshot.connectionState ==
|
|
||||||
ConnectionState.waiting) {
|
|
||||||
if (_isPreviousData) {
|
|
||||||
return JobDisplayPanel(
|
|
||||||
jobGroupedBusinesses:
|
|
||||||
_filterBySearch(overviewBusinesses, searchQuery),
|
|
||||||
widescreen: widescreen,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: const SizedBox(
|
|
||||||
width: 75,
|
|
||||||
height: 75,
|
|
||||||
child: RiveAnimation.asset(
|
|
||||||
'assets/mdev_triangle_loading.riv'),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
'\nError: ${snapshot.error}',
|
|
||||||
style: const TextStyle(fontSize: 18),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _filterIconButton(
|
|
||||||
Set<JobType> jobTypeFilters, Set<OfferType> offerTypeFilters) {
|
|
||||||
Set<JobType> selectedJobTypeChips = Set.from(jobTypeFilters);
|
|
||||||
Set<OfferType> selectedOfferTypeChips = Set.from(offerTypeFilters);
|
|
||||||
|
|
||||||
return IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.filter_list,
|
|
||||||
color: jobTypeFilters.isNotEmpty
|
|
||||||
? Theme.of(context).colorScheme.primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
selectedJobTypeChips = Set.from(jobTypeFilters);
|
|
||||||
selectedOfferTypeChips = Set.from(offerTypeFilters);
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
void setDialogState(Set<JobType>? newJobTypeFilters,
|
|
||||||
Set<OfferType>? newOfferTypeFilters) {
|
|
||||||
if (newJobTypeFilters != null) {
|
|
||||||
setState(() {
|
|
||||||
selectedJobTypeChips = newJobTypeFilters;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (newOfferTypeFilters != null) {
|
|
||||||
setState(() {
|
|
||||||
selectedOfferTypeChips = newOfferTypeFilters;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> jobTypeChips = [];
|
|
||||||
for (JobType type in JobType.values) {
|
|
||||||
jobTypeChips.add(FilterChip(
|
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
showCheckmark: false,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
side: BorderSide(
|
|
||||||
color:
|
|
||||||
Theme.of(context).colorScheme.secondary)),
|
|
||||||
selectedColor: Theme.of(context).colorScheme.secondary,
|
|
||||||
label: Text(
|
|
||||||
getNameFromJobType(type),
|
|
||||||
style: TextStyle(
|
|
||||||
color: selectedJobTypeChips.contains(type)
|
|
||||||
? Theme.of(context).colorScheme.onSecondary
|
|
||||||
: Theme.of(context).colorScheme.onSurface),
|
|
||||||
),
|
|
||||||
selected: selectedJobTypeChips.contains(type),
|
|
||||||
onSelected: (bool selected) {
|
|
||||||
if (selected) {
|
|
||||||
selectedJobTypeChips.add(type);
|
|
||||||
} else {
|
|
||||||
selectedJobTypeChips.remove(type);
|
|
||||||
}
|
|
||||||
setDialogState(selectedJobTypeChips, null);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> offerTypeChips = [];
|
|
||||||
for (OfferType type in OfferType.values) {
|
|
||||||
offerTypeChips.add(FilterChip(
|
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
showCheckmark: false,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
side: BorderSide(
|
|
||||||
color:
|
|
||||||
Theme.of(context).colorScheme.secondary)),
|
|
||||||
selectedColor: Theme.of(context).colorScheme.secondary,
|
|
||||||
label: Text(
|
|
||||||
getNameFromOfferType(type),
|
|
||||||
style: TextStyle(
|
|
||||||
color: selectedOfferTypeChips.contains(type)
|
|
||||||
? Theme.of(context).colorScheme.onSecondary
|
|
||||||
: Theme.of(context).colorScheme.onSurface),
|
|
||||||
),
|
|
||||||
selected: selectedOfferTypeChips.contains(type),
|
|
||||||
onSelected: (bool selected) {
|
|
||||||
if (selected) {
|
|
||||||
selectedOfferTypeChips.add(type);
|
|
||||||
} else {
|
|
||||||
selectedOfferTypeChips.remove(type);
|
|
||||||
}
|
|
||||||
setDialogState(null, selectedOfferTypeChips);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Filter Options'),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 400,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const Text('Job Type Filters:'),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8,
|
|
||||||
runSpacing: 8,
|
|
||||||
children: jobTypeChips,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Text('Offer Type Filters:'),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8,
|
|
||||||
runSpacing: 8,
|
|
||||||
children: offerTypeChips,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Reset'),
|
|
||||||
onPressed: () {
|
|
||||||
_setFilters(<JobType>{}, <OfferType>{});
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
onPressed: () {
|
|
||||||
// setDialogState(jobTypeFilters, offerTypeFilters);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Apply'),
|
|
||||||
onPressed: () {
|
|
||||||
_setFilters(
|
|
||||||
selectedJobTypeChips, selectedOfferTypeChips);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? _getFAB(bool widescreen) {
|
|
||||||
if (!widescreen && loggedIn) {
|
|
||||||
return FloatingActionButton.extended(
|
|
||||||
extendedIconLabelSpacing: _extended ? 8.0 : 0,
|
|
||||||
extendedPadding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
icon: const Icon(Icons.add),
|
|
||||||
label: AnimatedSize(
|
|
||||||
curve: Easing.standard,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
child: _extended ? const Text('Add Job Listing') : Container(),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const CreateEditJobListing()));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class JobDisplayPanel extends StatefulWidget {
|
|
||||||
final Map<JobType, List<Business>> jobGroupedBusinesses;
|
|
||||||
final bool widescreen;
|
|
||||||
|
|
||||||
const JobDisplayPanel({
|
|
||||||
super.key,
|
|
||||||
required this.jobGroupedBusinesses,
|
|
||||||
required this.widescreen,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<JobDisplayPanel> createState() => _JobDisplayPanelState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _JobDisplayPanelState extends State<JobDisplayPanel> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (widget.jobGroupedBusinesses.keys.isEmpty) {
|
|
||||||
return const SliverToBoxAdapter(
|
|
||||||
child: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: Text(
|
|
||||||
'No results found!\nPlease change your search filters.',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<_JobHeader> headers = [];
|
|
||||||
for (JobType jobType in widget.jobGroupedBusinesses.keys) {
|
|
||||||
headers.add(_JobHeader(
|
|
||||||
jobType: jobType,
|
|
||||||
widescreen: widget.widescreen,
|
|
||||||
businesses: widget.jobGroupedBusinesses[jobType]!));
|
|
||||||
}
|
|
||||||
headers.sort((a, b) => a.jobType.index.compareTo(b.jobType.index));
|
|
||||||
return MultiSliver(children: headers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _JobHeader extends StatefulWidget {
|
|
||||||
final JobType jobType;
|
|
||||||
final List<Business> businesses;
|
|
||||||
final bool widescreen;
|
|
||||||
|
|
||||||
const _JobHeader({
|
|
||||||
required this.jobType,
|
|
||||||
required this.businesses,
|
|
||||||
required this.widescreen,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_JobHeader> createState() => _JobHeaderState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _JobHeaderState extends State<_JobHeader> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SliverStickyHeader(
|
|
||||||
header: Container(
|
|
||||||
height: 55.0,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: _getHeaderRow(),
|
|
||||||
),
|
|
||||||
sliver: _getChildSliver(widget.businesses, widget.widescreen),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getHeaderRow() {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 4.0, right: 12.0),
|
|
||||||
child: Icon(
|
|
||||||
getIconFromJobType(widget.jobType),
|
|
||||||
color: Theme.of(context).colorScheme.onPrimary,
|
|
||||||
)),
|
|
||||||
Text(getNameFromJobType(widget.jobType),
|
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.onPrimary)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _getChildSliver(List<Business> businesses, bool widescreen) {
|
|
||||||
if (widescreen) {
|
|
||||||
return SliverPadding(
|
|
||||||
padding: const EdgeInsets.all(4),
|
|
||||||
sliver: SliverGrid(
|
|
||||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
mainAxisExtent: 250.0,
|
|
||||||
maxCrossAxisExtent: 400.0,
|
|
||||||
mainAxisSpacing: 4.0,
|
|
||||||
crossAxisSpacing: 4.0,
|
|
||||||
),
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
childCount: businesses.length,
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
return _jobBusinessTile(
|
|
||||||
businesses[index],
|
|
||||||
widget.jobType,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return SliverList(
|
|
||||||
delegate: SliverChildBuilderDelegate(
|
|
||||||
childCount: businesses.length,
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
return _jobBusinessListItem(
|
|
||||||
businesses[index],
|
|
||||||
widget.jobType,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A desktop widget that displays basic info about a job
|
|
||||||
Widget _jobBusinessTile(Business business, JobType jobType) {
|
|
||||||
return MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => JobListingDetail(
|
|
||||||
listing: business.listings![0],
|
|
||||||
fromBusiness: business,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
child: Card(
|
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Badge(
|
|
||||||
label: Text(
|
|
||||||
getLetterFromOfferType(
|
|
||||||
business.listings![0].offerType!),
|
|
||||||
style: const TextStyle(fontSize: 16),
|
|
||||||
),
|
|
||||||
largeSize: 24,
|
|
||||||
offset: const Offset(12, -3),
|
|
||||||
textColor: Colors.white,
|
|
||||||
backgroundColor: getColorFromOfferType(
|
|
||||||
business.listings![0].offerType!),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(6.0),
|
|
||||||
child: Image.network(
|
|
||||||
'$apiAddress/logos/${business.id}',
|
|
||||||
height: 48,
|
|
||||||
width: 48, errorBuilder: (BuildContext context,
|
|
||||||
Object exception, StackTrace? stackTrace) {
|
|
||||||
return Icon(
|
|
||||||
getIconFromJobType(business.listings![0].type!),
|
|
||||||
size: 48);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
Flexible(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
'${business.listings![0].name} (${getNameFromOfferType(business.listings![0].offerType!)})',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18, fontWeight: FontWeight.bold),
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
business.listings![0].description,
|
|
||||||
maxLines: 5,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
if (business.listings![0].link != null &&
|
|
||||||
business.listings![0].link!.isNotEmpty)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.link),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(Uri.parse(business.listings![0].link!));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.location_on),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(Uri.parse(Uri.encodeFull(
|
|
||||||
'https://www.google.com/maps/search/?api=1&query=${business.locationName}')));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (business.contactPhone != null)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.phone),
|
|
||||||
onPressed: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.surface,
|
|
||||||
title:
|
|
||||||
Text('Contact ${business.contactName}'),
|
|
||||||
content: Text(
|
|
||||||
'Would you like to call or text ${business.contactName}?'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Text'),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(Uri.parse(
|
|
||||||
'sms:${business.contactPhone}'));
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Call'),
|
|
||||||
onPressed: () async {
|
|
||||||
launchUrl(Uri.parse(
|
|
||||||
'tel:${business.contactPhone}'));
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (business.contactEmail != null)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.email),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(
|
|
||||||
Uri.parse('mailto:${business.contactEmail}'));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A mobile widget that displays basic info about a job
|
|
||||||
Widget _jobBusinessListItem(Business business, JobType? jobType) {
|
|
||||||
return Card(
|
|
||||||
child: ListTile(
|
|
||||||
leading: Badge(
|
|
||||||
label: Text(getLetterFromOfferType(business.listings![0].offerType!)),
|
|
||||||
textColor: Colors.white,
|
|
||||||
isLabelVisible: true,
|
|
||||||
offset: const Offset(7, -5),
|
|
||||||
alignment: Alignment.topRight,
|
|
||||||
padding: business.listings![0].offerType! == OfferType.internship
|
|
||||||
? const EdgeInsets.symmetric(horizontal: 5)
|
|
||||||
: null,
|
|
||||||
backgroundColor:
|
|
||||||
getColorFromOfferType(business.listings![0].offerType!),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(3.0),
|
|
||||||
child: Image.network('$apiAddress/logos/${business.id}',
|
|
||||||
height: 24, width: 24, errorBuilder: (BuildContext context,
|
|
||||||
Object exception, StackTrace? stackTrace) {
|
|
||||||
return Icon(
|
|
||||||
getIconFromJobType(business.listings![0].type!),
|
|
||||||
);
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'${business.listings![0].name} (${getNameFromOfferType(business.listings![0].offerType!)})'),
|
|
||||||
subtitle: Text(business.listings![0].description,
|
|
||||||
maxLines: 2, overflow: TextOverflow.ellipsis),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: (context) => JobListingDetail(
|
|
||||||
listing: business.listings![0],
|
|
||||||
fromBusiness: business,
|
|
||||||
)));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +1,13 @@
|
|||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
import 'package:fbla_ui/api_logic.dart';
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
import 'package:fbla_ui/home.dart';
|
||||||
|
import 'package:fbla_ui/shared.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
bool loggedIn = false;
|
||||||
|
|
||||||
class SignInPage extends StatefulWidget {
|
class SignInPage extends StatefulWidget {
|
||||||
final void Function(bool) refreshAccount;
|
final Callback refreshAccount;
|
||||||
|
|
||||||
const SignInPage({super.key, required this.refreshAccount});
|
const SignInPage({super.key, required this.refreshAccount});
|
||||||
|
|
||||||
@ -37,7 +40,7 @@ class _SignInPageState extends State<SignInPage> {
|
|||||||
heightFactor: 1.0,
|
heightFactor: 1.0,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.fromLTRB(12, 50, 12, 50),
|
padding: const EdgeInsets.fromLTRB(12, 50, 12, 50),
|
||||||
height: 450,
|
height: 475,
|
||||||
width: 500,
|
width: 500,
|
||||||
child: Card(
|
child: Card(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@ -60,12 +63,9 @@ class _SignInPageState extends State<SignInPage> {
|
|||||||
controller: _usernameController,
|
controller: _usernameController,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
prefixIcon: Padding(
|
prefixIcon: Icon(Icons.person_outline),
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: Icon(Icons.person_outline),
|
|
||||||
),
|
|
||||||
labelText: 'Username',
|
labelText: 'Username',
|
||||||
),
|
border: OutlineInputBorder()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
@ -97,7 +97,8 @@ class _SignInPageState extends State<SignInPage> {
|
|||||||
await prefs.setString('username', username);
|
await prefs.setString('username', username);
|
||||||
await prefs.setString('password', password);
|
await prefs.setString('password', password);
|
||||||
await prefs.setBool('rememberMe', rememberMe);
|
await prefs.setBool('rememberMe', rememberMe);
|
||||||
widget.refreshAccount(true);
|
loggedIn = true;
|
||||||
|
widget.refreshAccount();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -110,13 +111,11 @@ class _SignInPageState extends State<SignInPage> {
|
|||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
obscureText: obscurePassword,
|
obscureText: obscurePassword,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
prefixIcon: const Padding(
|
prefixIcon: const Icon(Icons.fingerprint),
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: Icon(Icons.fingerprint),
|
|
||||||
),
|
|
||||||
labelText: 'Password',
|
labelText: 'Password',
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
suffixIcon: Padding(
|
suffixIcon: Padding(
|
||||||
padding: const EdgeInsets.only(right: 16.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -136,45 +135,35 @@ class _SignInPageState extends State<SignInPage> {
|
|||||||
errorMessage!,
|
errorMessage!,
|
||||||
style: const TextStyle(color: Colors.red),
|
style: const TextStyle(color: Colors.red),
|
||||||
),
|
),
|
||||||
Padding(
|
CheckboxListTile(
|
||||||
padding: const EdgeInsets.only(
|
value: rememberMe,
|
||||||
top: 8.0, left: 8.0, right: 8.0),
|
onChanged: (value) async {
|
||||||
child: FilledButton(
|
setState(() {
|
||||||
style: FilledButton.styleFrom(
|
rememberMe = value!;
|
||||||
shape: const RoundedRectangleBorder(
|
});
|
||||||
borderRadius:
|
},
|
||||||
BorderRadius.all(Radius.circular(6)))),
|
title: const Text('Remember me'),
|
||||||
child: SizedBox(
|
),
|
||||||
width: 374,
|
ElevatedButton.icon(
|
||||||
height: 40,
|
style: ElevatedButton.styleFrom(
|
||||||
child: Row(
|
backgroundColor:
|
||||||
mainAxisSize: MainAxisSize.min,
|
Theme.of(context).colorScheme.primary,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
// padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 12.0, bottom: 12.0),
|
||||||
children: [
|
),
|
||||||
_isloading
|
icon: _isloading
|
||||||
? const Padding(
|
? const SizedBox(
|
||||||
padding: EdgeInsets.only(right: 8.0),
|
|
||||||
child: SizedBox(
|
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
)),
|
))
|
||||||
)
|
: const Icon(Icons.done, color: Colors.white),
|
||||||
: const Padding(
|
label: const Text('Sign In',
|
||||||
padding: EdgeInsets.only(right: 8.0),
|
style: TextStyle(color: Colors.white)),
|
||||||
child: Icon(Icons.done,
|
|
||||||
color: Colors.white),
|
|
||||||
),
|
|
||||||
const Text('Sign in',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white, fontSize: 18)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
errorMessage = null;
|
||||||
_isloading = true;
|
_isloading = true;
|
||||||
});
|
});
|
||||||
jwt = await signIn(username, password).timeout(
|
jwt = await signIn(username, password).timeout(
|
||||||
@ -194,7 +183,8 @@ class _SignInPageState extends State<SignInPage> {
|
|||||||
await prefs.setString('username', username);
|
await prefs.setString('username', username);
|
||||||
await prefs.setString('password', password);
|
await prefs.setString('password', password);
|
||||||
await prefs.setBool('rememberMe', rememberMe);
|
await prefs.setBool('rememberMe', rememberMe);
|
||||||
widget.refreshAccount(true);
|
loggedIn = true;
|
||||||
|
widget.refreshAccount();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -204,44 +194,6 @@ class _SignInPageState extends State<SignInPage> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Checkbox(
|
|
||||||
value: rememberMe,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
rememberMe = value!;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: Text('Remember me'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
rememberMe = !rememberMe;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
761
fbla_ui/lib/shared.dart
Normal file
761
fbla_ui/lib/shared.dart
Normal file
@ -0,0 +1,761 @@
|
|||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:fbla_ui/api_logic.dart';
|
||||||
|
import 'package:fbla_ui/pages/business_detail.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
|
||||||
|
import 'package:pdf/pdf.dart';
|
||||||
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
|
import 'package:sliver_tools/sliver_tools.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
late String jwt;
|
||||||
|
Set<BusinessType> filters = <BusinessType>{};
|
||||||
|
Set<BusinessType> selectedChips = <BusinessType>{};
|
||||||
|
String searchFilter = '';
|
||||||
|
bool isFiltered = false;
|
||||||
|
Set<Business> selectedBusinesses = <Business>{};
|
||||||
|
Set<DataType> selectedDataTypes = <DataType>{};
|
||||||
|
Set<DataType> dataTypeFilters = <DataType>{};
|
||||||
|
|
||||||
|
enum DataType {
|
||||||
|
logo,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
type,
|
||||||
|
website,
|
||||||
|
contactName,
|
||||||
|
contactEmail,
|
||||||
|
contactPhone,
|
||||||
|
notes,
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<DataType, int> dataTypeValues = {
|
||||||
|
DataType.logo: 0,
|
||||||
|
DataType.name: 1,
|
||||||
|
DataType.description: 2,
|
||||||
|
DataType.type: 3,
|
||||||
|
DataType.website: 4,
|
||||||
|
DataType.contactName: 5,
|
||||||
|
DataType.contactEmail: 6,
|
||||||
|
DataType.contactPhone: 7,
|
||||||
|
DataType.notes: 8
|
||||||
|
};
|
||||||
|
|
||||||
|
Map<DataType, String> dataTypeFriendly = {
|
||||||
|
DataType.logo: 'Logo',
|
||||||
|
DataType.name: 'Name',
|
||||||
|
DataType.description: 'Description',
|
||||||
|
DataType.type: 'Type',
|
||||||
|
DataType.website: 'Website',
|
||||||
|
DataType.contactName: 'Contact Name',
|
||||||
|
DataType.contactEmail: 'Contact Email',
|
||||||
|
DataType.contactPhone: 'Contact Phone',
|
||||||
|
DataType.notes: 'Notes'
|
||||||
|
};
|
||||||
|
|
||||||
|
Set<DataType> sortDataTypes(Set<DataType> set) {
|
||||||
|
List<DataType> list = set.toList();
|
||||||
|
list.sort((a, b) {
|
||||||
|
return dataTypeValues[a]!.compareTo(dataTypeValues[b]!);
|
||||||
|
});
|
||||||
|
set = list.toSet();
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum BusinessType {
|
||||||
|
food,
|
||||||
|
shop,
|
||||||
|
outdoors,
|
||||||
|
manufacturing,
|
||||||
|
other,
|
||||||
|
}
|
||||||
|
|
||||||
|
class Business {
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
String description;
|
||||||
|
BusinessType type;
|
||||||
|
String website;
|
||||||
|
String contactName;
|
||||||
|
String contactEmail;
|
||||||
|
String contactPhone;
|
||||||
|
String notes;
|
||||||
|
String locationName;
|
||||||
|
String locationAddress;
|
||||||
|
|
||||||
|
Business({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.description,
|
||||||
|
required this.type,
|
||||||
|
required this.website,
|
||||||
|
required this.contactName,
|
||||||
|
required this.contactEmail,
|
||||||
|
required this.contactPhone,
|
||||||
|
required this.notes,
|
||||||
|
required this.locationName,
|
||||||
|
required this.locationAddress,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Business.fromJson(Map<String, dynamic> json) {
|
||||||
|
bool typeValid = true;
|
||||||
|
try {
|
||||||
|
BusinessType.values.byName(json['type']);
|
||||||
|
} catch (e) {
|
||||||
|
typeValid = false;
|
||||||
|
}
|
||||||
|
return Business(
|
||||||
|
id: json['id'],
|
||||||
|
name: json['name'],
|
||||||
|
description: json['description'],
|
||||||
|
type: typeValid
|
||||||
|
? BusinessType.values.byName(json['type'])
|
||||||
|
: BusinessType.other,
|
||||||
|
website: json['website'],
|
||||||
|
contactName: json['contactName'],
|
||||||
|
contactEmail: json['contactEmail'],
|
||||||
|
contactPhone: json['contactPhone'],
|
||||||
|
notes: json['notes'],
|
||||||
|
locationName: json['locationName'],
|
||||||
|
locationAddress: json['locationAddress'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Business.copy(Business input) {
|
||||||
|
return Business(
|
||||||
|
id: input.id,
|
||||||
|
name: input.name,
|
||||||
|
description: input.description,
|
||||||
|
type: input.type,
|
||||||
|
website: input.website,
|
||||||
|
contactName: input.contactName,
|
||||||
|
contactEmail: input.contactEmail,
|
||||||
|
contactPhone: input.contactPhone,
|
||||||
|
notes: input.notes,
|
||||||
|
locationName: input.locationName,
|
||||||
|
locationAddress: input.locationAddress,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<BusinessType, List<Business>> groupBusinesses(List<Business> businesses) {
|
||||||
|
Map<BusinessType, List<Business>> groupedBusinesses =
|
||||||
|
groupBy<Business, BusinessType>(businesses, (business) => business.type);
|
||||||
|
|
||||||
|
return groupedBusinesses;
|
||||||
|
}
|
||||||
|
|
||||||
|
Icon getIconFromType(BusinessType type, double size, Color color) {
|
||||||
|
switch (type) {
|
||||||
|
case BusinessType.food:
|
||||||
|
return Icon(
|
||||||
|
Icons.restaurant,
|
||||||
|
size: size,
|
||||||
|
color: color,
|
||||||
|
);
|
||||||
|
case BusinessType.shop:
|
||||||
|
return Icon(
|
||||||
|
Icons.store,
|
||||||
|
size: size,
|
||||||
|
color: color,
|
||||||
|
);
|
||||||
|
case BusinessType.outdoors:
|
||||||
|
return Icon(
|
||||||
|
Icons.forest,
|
||||||
|
size: size,
|
||||||
|
color: color,
|
||||||
|
);
|
||||||
|
case BusinessType.manufacturing:
|
||||||
|
return Icon(
|
||||||
|
Icons.factory,
|
||||||
|
size: size,
|
||||||
|
color: color,
|
||||||
|
);
|
||||||
|
case BusinessType.other:
|
||||||
|
return Icon(
|
||||||
|
Icons.business,
|
||||||
|
size: size,
|
||||||
|
color: color,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pw.Icon getPwIconFromType(BusinessType type, double size, PdfColor color) {
|
||||||
|
switch (type) {
|
||||||
|
case BusinessType.food:
|
||||||
|
return pw.Icon(const pw.IconData(0xe56c), size: size, color: color);
|
||||||
|
case BusinessType.shop:
|
||||||
|
return pw.Icon(const pw.IconData(0xea12), size: size, color: color);
|
||||||
|
case BusinessType.outdoors:
|
||||||
|
return pw.Icon(const pw.IconData(0xea99), size: size, color: color);
|
||||||
|
case BusinessType.manufacturing:
|
||||||
|
return pw.Icon(const pw.IconData(0xebbc), size: size, color: color);
|
||||||
|
case BusinessType.other:
|
||||||
|
return pw.Icon(const pw.IconData(0xe0af), size: size, color: color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text getNameFromType(BusinessType type, Color color) {
|
||||||
|
switch (type) {
|
||||||
|
case BusinessType.food:
|
||||||
|
return Text('Food Related', style: TextStyle(color: color));
|
||||||
|
case BusinessType.shop:
|
||||||
|
return Text('Shops', style: TextStyle(color: color));
|
||||||
|
case BusinessType.outdoors:
|
||||||
|
return Text('Outdoors', style: TextStyle(color: color));
|
||||||
|
case BusinessType.manufacturing:
|
||||||
|
return Text('Manufacturing', style: TextStyle(color: color));
|
||||||
|
case BusinessType.other:
|
||||||
|
return Text('Other', style: TextStyle(color: color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Icon getIconFromThemeMode(ThemeMode theme) {
|
||||||
|
switch (theme) {
|
||||||
|
case ThemeMode.dark:
|
||||||
|
return const Icon(Icons.dark_mode);
|
||||||
|
case ThemeMode.light:
|
||||||
|
return const Icon(Icons.light_mode);
|
||||||
|
case ThemeMode.system:
|
||||||
|
return const Icon(Icons.brightness_4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BusinessDisplayPanel extends StatefulWidget {
|
||||||
|
final List<Business> businesses;
|
||||||
|
final bool widescreen;
|
||||||
|
final bool selectable;
|
||||||
|
|
||||||
|
const BusinessDisplayPanel(
|
||||||
|
{super.key,
|
||||||
|
required this.businesses,
|
||||||
|
required this.widescreen,
|
||||||
|
required this.selectable});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BusinessDisplayPanel> createState() => _BusinessDisplayPanelState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BusinessDisplayPanelState extends State<BusinessDisplayPanel> {
|
||||||
|
Set<Business> selectedBusinesses = <Business>{};
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<BusinessHeader> headers = [];
|
||||||
|
List<Business> filteredBusinesses = [];
|
||||||
|
for (var business in widget.businesses) {
|
||||||
|
if (business.name.toLowerCase().contains(searchFilter.toLowerCase())) {
|
||||||
|
filteredBusinesses.add(business);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var groupedBusinesses = groupBusinesses(filteredBusinesses);
|
||||||
|
var businessTypes = groupedBusinesses.keys.toList();
|
||||||
|
|
||||||
|
for (var i = 0; i < businessTypes.length; i++) {
|
||||||
|
if (filters.contains(businessTypes[i])) {
|
||||||
|
isFiltered = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFiltered) {
|
||||||
|
for (var i = 0; i < businessTypes.length; i++) {
|
||||||
|
if (filters.contains(businessTypes[i])) {
|
||||||
|
headers.add(BusinessHeader(
|
||||||
|
type: businessTypes[i],
|
||||||
|
widescreen: widget.widescreen,
|
||||||
|
selectable: widget.selectable,
|
||||||
|
selectedBusinesses: selectedBusinesses,
|
||||||
|
businesses: groupedBusinesses[businessTypes[i]]!));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < businessTypes.length; i++) {
|
||||||
|
headers.add(BusinessHeader(
|
||||||
|
type: businessTypes[i],
|
||||||
|
widescreen: widget.widescreen,
|
||||||
|
selectable: widget.selectable,
|
||||||
|
selectedBusinesses: selectedBusinesses,
|
||||||
|
businesses: groupedBusinesses[businessTypes[i]]!));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.sort((a, b) => a.type.index.compareTo(b.type.index));
|
||||||
|
return MultiSliver(children: headers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BusinessHeader extends StatefulWidget {
|
||||||
|
final BusinessType type;
|
||||||
|
final List<Business> businesses;
|
||||||
|
final Set<Business> selectedBusinesses;
|
||||||
|
final bool widescreen;
|
||||||
|
final bool selectable;
|
||||||
|
|
||||||
|
const BusinessHeader({
|
||||||
|
super.key,
|
||||||
|
required this.type,
|
||||||
|
required this.businesses,
|
||||||
|
required this.selectedBusinesses,
|
||||||
|
required this.widescreen,
|
||||||
|
required this.selectable,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BusinessHeader> createState() => _BusinessHeaderState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BusinessHeaderState extends State<BusinessHeader> {
|
||||||
|
refresh() {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SliverStickyHeader(
|
||||||
|
header: Container(
|
||||||
|
height: 55.0,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: _getHeaderRow(widget.selectable),
|
||||||
|
),
|
||||||
|
sliver: _getChildSliver(
|
||||||
|
widget.businesses, widget.widescreen, widget.selectable),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _getHeaderRow(bool selectable) {
|
||||||
|
if (selectable) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4.0, right: 12.0),
|
||||||
|
child: getIconFromType(
|
||||||
|
widget.type, 24, Theme.of(context).colorScheme.onPrimary),
|
||||||
|
),
|
||||||
|
getNameFromType(
|
||||||
|
widget.type, Theme.of(context).colorScheme.onPrimary),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 12.0),
|
||||||
|
child: Checkbox(
|
||||||
|
checkColor: Theme.of(context).colorScheme.primary,
|
||||||
|
activeColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
|
value: selectedBusinesses.containsAll(widget.businesses),
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value!) {
|
||||||
|
setState(() {
|
||||||
|
selectedBusinesses.addAll(widget.businesses);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
selectedBusinesses.removeAll(widget.businesses);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4.0, right: 12.0),
|
||||||
|
child: getIconFromType(
|
||||||
|
widget.type, 24, Theme.of(context).colorScheme.onPrimary),
|
||||||
|
),
|
||||||
|
getNameFromType(widget.type, Theme.of(context).colorScheme.onPrimary),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _getChildSliver(
|
||||||
|
List<Business> businesses, bool widescreen, bool selectable) {
|
||||||
|
if (widescreen) {
|
||||||
|
return SliverGrid(
|
||||||
|
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
|
mainAxisExtent: 250.0,
|
||||||
|
maxCrossAxisExtent: 400.0,
|
||||||
|
mainAxisSpacing: 10.0,
|
||||||
|
crossAxisSpacing: 10.0,
|
||||||
|
// childAspectRatio: 4.0,
|
||||||
|
),
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
childCount: businesses.length,
|
||||||
|
(BuildContext context, int index) {
|
||||||
|
return BusinessCard(
|
||||||
|
business: businesses[index],
|
||||||
|
selectable: selectable,
|
||||||
|
widescreen: widescreen,
|
||||||
|
callback: refresh,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return SliverList(
|
||||||
|
delegate: SliverChildBuilderDelegate(
|
||||||
|
childCount: businesses.length,
|
||||||
|
(BuildContext context, int index) {
|
||||||
|
return BusinessCard(
|
||||||
|
business: businesses[index],
|
||||||
|
selectable: selectable,
|
||||||
|
widescreen: widescreen,
|
||||||
|
callback: refresh,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BusinessCard extends StatefulWidget {
|
||||||
|
final Business business;
|
||||||
|
final bool widescreen;
|
||||||
|
final bool selectable;
|
||||||
|
final Function callback;
|
||||||
|
|
||||||
|
const BusinessCard(
|
||||||
|
{super.key,
|
||||||
|
required this.business,
|
||||||
|
required this.widescreen,
|
||||||
|
required this.selectable,
|
||||||
|
required this.callback});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BusinessCard> createState() => _BusinessCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BusinessCardState extends State<BusinessCard> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (widget.widescreen) {
|
||||||
|
return _businessTile(widget.business, widget.selectable);
|
||||||
|
} else {
|
||||||
|
return _businessListItem(
|
||||||
|
widget.business, widget.selectable, widget.callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _businessTile(Business business, bool selectable) {
|
||||||
|
return MouseRegion(
|
||||||
|
cursor: SystemMouseCursors.click,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
|
builder: (context) => BusinessDetail(inputBusiness: business)));
|
||||||
|
},
|
||||||
|
child: Card(
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_getTileRow(business, selectable, widget.callback),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
business.description,
|
||||||
|
maxLines: selectable ? 7 : 5,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: !selectable
|
||||||
|
? Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.link),
|
||||||
|
onPressed: () {
|
||||||
|
launchUrl(
|
||||||
|
Uri.parse('https://${business.website}'));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (business.locationName.isNotEmpty)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.location_on),
|
||||||
|
onPressed: () {
|
||||||
|
launchUrl(Uri.parse(Uri.encodeFull(
|
||||||
|
'https://www.google.com/maps/search/?api=1&query=${business.locationName}')));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (business.contactPhone.isNotEmpty)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.phone),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
backgroundColor: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.background,
|
||||||
|
title: Text(
|
||||||
|
'Contact ${business.contactName}?'),
|
||||||
|
content: Text(
|
||||||
|
'Would you like to call or text ${business.contactName}?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Text'),
|
||||||
|
onPressed: () {
|
||||||
|
launchUrl(Uri.parse(
|
||||||
|
'sms:${business.contactPhone}'));
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Call'),
|
||||||
|
onPressed: () async {
|
||||||
|
launchUrl(Uri.parse(
|
||||||
|
'tel:${business.contactPhone}'));
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (business.contactEmail.isNotEmpty)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.email),
|
||||||
|
onPressed: () {
|
||||||
|
launchUrl(Uri.parse(
|
||||||
|
'mailto:${business.contactEmail}'));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: null),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _getTileRow(Business business, bool selectable, Function callback) {
|
||||||
|
if (selectable) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(6.0),
|
||||||
|
child: Image.network('$apiAddress/logos/${business.id}',
|
||||||
|
height: 48, width: 48, errorBuilder: (BuildContext context,
|
||||||
|
Object exception, StackTrace? stackTrace) {
|
||||||
|
return getIconFromType(
|
||||||
|
business.type, 48, Theme.of(context).colorScheme.onSurface);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
business.name,
|
||||||
|
style:
|
||||||
|
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 24.0),
|
||||||
|
child: _checkbox(callback),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(6.0),
|
||||||
|
child: Image.network('$apiAddress/logos/${business.id}',
|
||||||
|
height: 48, width: 48, errorBuilder: (BuildContext context,
|
||||||
|
Object exception, StackTrace? stackTrace) {
|
||||||
|
return getIconFromType(business.type, 48,
|
||||||
|
Theme.of(context).colorScheme.onSurface);
|
||||||
|
}),
|
||||||
|
)),
|
||||||
|
Flexible(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
business.name,
|
||||||
|
style:
|
||||||
|
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _businessListItem(
|
||||||
|
Business business, bool selectable, Function callback) {
|
||||||
|
return Card(
|
||||||
|
child: ListTile(
|
||||||
|
leading: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(3.0),
|
||||||
|
child: Image.network('$apiAddress/logos/${business.id}',
|
||||||
|
height: 24, width: 24, errorBuilder: (BuildContext context,
|
||||||
|
Object exception, StackTrace? stackTrace) {
|
||||||
|
return getIconFromType(
|
||||||
|
business.type, 24, Theme.of(context).colorScheme.onSurface);
|
||||||
|
})),
|
||||||
|
title: Text(business.name),
|
||||||
|
subtitle: Text(business.description,
|
||||||
|
maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
trailing: _getCheckbox(selectable, callback),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
|
builder: (context) => BusinessDetail(inputBusiness: business)));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _checkbox(Function callback) {
|
||||||
|
return Checkbox(
|
||||||
|
value: selectedBusinesses.contains(widget.business),
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value!) {
|
||||||
|
setState(() {
|
||||||
|
selectedBusinesses.add(widget.business);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
selectedBusinesses.remove(widget.business);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _getCheckbox(bool selectable, Function callback) {
|
||||||
|
if (selectable) {
|
||||||
|
return _checkbox(callback);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilterChips extends StatefulWidget {
|
||||||
|
const FilterChips({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FilterChips> createState() => _FilterChipsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FilterChipsState extends State<FilterChips> {
|
||||||
|
List<Padding> filterChips() {
|
||||||
|
List<Padding> chips = [];
|
||||||
|
|
||||||
|
for (var type in BusinessType.values) {
|
||||||
|
chips.add(Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4.0, right: 4.0),
|
||||||
|
child: FilterChip(
|
||||||
|
showCheckmark: false,
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
|
label: Text(type.name),
|
||||||
|
selected: selectedChips.contains(type),
|
||||||
|
onSelected: (bool selected) {
|
||||||
|
setState(() {
|
||||||
|
if (selected) {
|
||||||
|
selectedChips.add(type);
|
||||||
|
} else {
|
||||||
|
selectedChips.remove(type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return chips;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Wrap(
|
||||||
|
children: filterChips(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilterDataTypeChips extends StatefulWidget {
|
||||||
|
const FilterDataTypeChips({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FilterDataTypeChips> createState() => _FilterDataTypeChipsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FilterDataTypeChipsState extends State<FilterDataTypeChips> {
|
||||||
|
List<Padding> filterDataTypeChips() {
|
||||||
|
List<Padding> chips = [];
|
||||||
|
|
||||||
|
for (var type in DataType.values) {
|
||||||
|
chips.add(Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(left: 3.0, right: 3.0, bottom: 3.0, top: 3.0),
|
||||||
|
// child: ActionChip(
|
||||||
|
// avatar: selectedDataTypes.contains(type) ? Icon(Icons.check_box) : Icon(Icons.check_box_outline_blank),
|
||||||
|
// label: Text(type.name),
|
||||||
|
// onPressed: () {
|
||||||
|
// if (!selectedDataTypes.contains(type)) {
|
||||||
|
// setState(() {
|
||||||
|
// selectedDataTypes.add(type);
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// setState(() {
|
||||||
|
// selectedDataTypes.remove(type);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
|
||||||
|
// ),
|
||||||
|
child: FilterChip(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
side:
|
||||||
|
BorderSide(color: Theme.of(context).colorScheme.secondary)),
|
||||||
|
label: Text(dataTypeFriendly[type]!),
|
||||||
|
showCheckmark: false,
|
||||||
|
selected: selectedDataTypes.contains(type),
|
||||||
|
onSelected: (bool selected) {
|
||||||
|
setState(() {
|
||||||
|
if (selected) {
|
||||||
|
selectedDataTypes.add(type);
|
||||||
|
} else {
|
||||||
|
selectedDataTypes.remove(type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return chips;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Wrap(
|
||||||
|
children: filterDataTypeChips(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,399 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
|
|
||||||
var apiAddress = 'https://homelab.marinodev.com/fbla-api';
|
|
||||||
// var apiAddress = 'http://192.168.0.114:8000/fbla-api'; // TODO
|
|
||||||
|
|
||||||
var client = http.Client();
|
|
||||||
|
|
||||||
Future fetchBusinessData() async {
|
|
||||||
try {
|
|
||||||
var response = await http
|
|
||||||
.get(Uri.parse('$apiAddress/businessdata'))
|
|
||||||
.timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
var decodedResponse = json.decode(response.body);
|
|
||||||
List<Business> businessList = List<Business>.from(
|
|
||||||
decodedResponse.map((json) => Business.fromJson(json)).toList());
|
|
||||||
return businessList;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}! Please try again later!';
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future fetchBusinessNames() async {
|
|
||||||
try {
|
|
||||||
var response = await http
|
|
||||||
.get(Uri.parse('$apiAddress/businessdata/businessnames'))
|
|
||||||
.timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
List<Map<String, dynamic>> decodedResponse =
|
|
||||||
json.decode(response.body).cast<Map<String, dynamic>>();
|
|
||||||
|
|
||||||
return decodedResponse;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}! Please try again later!';
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future fetchBusinessDataOverviewJobs(
|
|
||||||
{Iterable<JobType>? typeFilters, Iterable<OfferType>? offerFilters}) async {
|
|
||||||
try {
|
|
||||||
String uriString = '$apiAddress/businessdata/overview/jobs';
|
|
||||||
if (typeFilters != null && typeFilters.isNotEmpty) {
|
|
||||||
uriString +=
|
|
||||||
'?typeFilters=${typeFilters.map((jobType) => jobType.name).join(',')}';
|
|
||||||
if (offerFilters != null && offerFilters.isNotEmpty) {
|
|
||||||
uriString +=
|
|
||||||
'&offerFilters=${offerFilters.map((offerType) => offerType.name).join(',')}';
|
|
||||||
}
|
|
||||||
} else if (offerFilters != null && offerFilters.isNotEmpty) {
|
|
||||||
uriString +=
|
|
||||||
'?offerFilters=${offerFilters.map((offerType) => offerType.name).join(',')}';
|
|
||||||
}
|
|
||||||
Uri uri = Uri.parse(uriString);
|
|
||||||
|
|
||||||
var response = await http.get(uri).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
List<Map<String, dynamic>> decodedResponse =
|
|
||||||
json.decode(response.body).cast<Map<String, dynamic>>();
|
|
||||||
|
|
||||||
List<Business> initialBusinesses =
|
|
||||||
decodedResponse.map((element) => Business.fromJson(element)).toList();
|
|
||||||
|
|
||||||
Map<JobType, List<Business>> groupedBusinesses = {};
|
|
||||||
|
|
||||||
for (Business business in initialBusinesses) {
|
|
||||||
for (JobListing job in business.listings!) {
|
|
||||||
List<Business> newBusinesses = groupedBusinesses[job.type!] ?? [];
|
|
||||||
Business newBusiness = Business.copy(business);
|
|
||||||
newBusiness.listings =
|
|
||||||
newBusiness.listings!.where((element) => element == job).toList();
|
|
||||||
newBusinesses.add(newBusiness);
|
|
||||||
groupedBusinesses.addAll({job.type!: newBusinesses});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return groupedBusinesses;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}! Please try again later!';
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future fetchBusinessDataOverviewTypes({List<BusinessType>? typeFilters}) async {
|
|
||||||
try {
|
|
||||||
String? typeString =
|
|
||||||
typeFilters?.map((jobType) => jobType.name).toList().join(',');
|
|
||||||
Uri uri = Uri.parse(
|
|
||||||
'$apiAddress/businessdata/overview/types?filters=$typeString');
|
|
||||||
if (typeFilters == null || typeFilters.isEmpty) {
|
|
||||||
uri = Uri.parse('$apiAddress/businessdata/overview/types');
|
|
||||||
}
|
|
||||||
var response = await http.get(uri).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
var decodedResponse = json.decode(response.body);
|
|
||||||
Map<BusinessType, List<Business>> groupedBusinesses = {};
|
|
||||||
|
|
||||||
for (String stringType in decodedResponse.keys) {
|
|
||||||
List<Business> businesses = [];
|
|
||||||
|
|
||||||
for (Map<String, dynamic> map in decodedResponse[stringType]) {
|
|
||||||
map.addAll({'type': stringType});
|
|
||||||
Business business = Business.fromJson(map);
|
|
||||||
businesses.add(business);
|
|
||||||
}
|
|
||||||
|
|
||||||
groupedBusinesses
|
|
||||||
.addAll({BusinessType.values.byName(stringType): businesses});
|
|
||||||
}
|
|
||||||
return groupedBusinesses;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}! Please try again later!';
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future fetchBusinesses(List<int> ids) async {
|
|
||||||
try {
|
|
||||||
var response = await http
|
|
||||||
.get(Uri.parse(
|
|
||||||
'$apiAddress/businessdata/businesses?businesses=${ids.join(',')}'))
|
|
||||||
.timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
List<dynamic> decodedResponse = json.decode(response.body);
|
|
||||||
|
|
||||||
List<Business> businesses = decodedResponse
|
|
||||||
.map<Business>((json) => Business.fromJson(json))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
return businesses;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}! Please try again later!';
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future fetchBusiness(int id) async {
|
|
||||||
try {
|
|
||||||
var response = await http
|
|
||||||
.get(Uri.parse('$apiAddress/businessdata/business/$id'))
|
|
||||||
.timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
var decodedResponse = json.decode(response.body);
|
|
||||||
Business business = Business.fromJson(decodedResponse);
|
|
||||||
|
|
||||||
return business;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}! Please try again later!';
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future fetchJob(int id) async {
|
|
||||||
try {
|
|
||||||
var response = await http
|
|
||||||
.get(Uri.parse('$apiAddress/businessdata/jobs/$id'))
|
|
||||||
.timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
var decodedResponse = json.decode(response.body);
|
|
||||||
Business business = Business.fromJson(decodedResponse);
|
|
||||||
|
|
||||||
return business;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}! Please try again later!';
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout).\nPlease try again later.';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception).\nPlease check your internet connection.\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future createBusiness(Business business) async {
|
|
||||||
var json = '''
|
|
||||||
{
|
|
||||||
"id": ${business.id},
|
|
||||||
"name": "${business.name}",
|
|
||||||
"description": "${business.description?.replaceAll('\n', '\\n')}",
|
|
||||||
"website": "${business.website}",
|
|
||||||
"type": "${business.type!.name}",
|
|
||||||
"contactName": "${business.contactName}",
|
|
||||||
"contactEmail": "${business.contactEmail}",
|
|
||||||
"contactPhone": "${business.contactPhone}",
|
|
||||||
"notes": "${business.notes}",
|
|
||||||
"locationName": "${business.locationName}",
|
|
||||||
"locationAddress": "${business.locationAddress}"
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
try {
|
|
||||||
var response = await http.post(Uri.parse('$apiAddress/createbusiness'),
|
|
||||||
body: json,
|
|
||||||
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout). Please try again later';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future createListing(JobListing listing) async {
|
|
||||||
var json = '''
|
|
||||||
{
|
|
||||||
"id": ${listing.id},
|
|
||||||
"businessId": ${listing.businessId},
|
|
||||||
"name": "${listing.name}",
|
|
||||||
"description": "${listing.description.replaceAll('\n', '\\n')}",
|
|
||||||
"type": "${listing.type!.name}",
|
|
||||||
"offerType": "${listing.offerType!.name}",
|
|
||||||
"wage": "${listing.wage}",
|
|
||||||
"link": "${listing.link}"
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
try {
|
|
||||||
var response = await http.post(Uri.parse('$apiAddress/createlisting'),
|
|
||||||
body: json,
|
|
||||||
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout). Please try again later';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future deleteBusiness(int id) async {
|
|
||||||
var json = '''
|
|
||||||
{
|
|
||||||
"id": $id
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
try {
|
|
||||||
var response = await http.post(Uri.parse('$apiAddress/deletebusiness'),
|
|
||||||
body: json,
|
|
||||||
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout). Please try again later';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future deleteListing(int id) async {
|
|
||||||
var json = '''
|
|
||||||
{
|
|
||||||
"id": $id
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
try {
|
|
||||||
var response = await http.post(Uri.parse('$apiAddress/deletelisting'),
|
|
||||||
body: json,
|
|
||||||
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout). Please try again later';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future editBusiness(Business business) async {
|
|
||||||
var json = '''
|
|
||||||
{
|
|
||||||
"id": ${business.id},
|
|
||||||
"name": "${business.name}",
|
|
||||||
"description": "${business.description?.replaceAll('\n', '\\n')}",
|
|
||||||
"website": "${business.website}",
|
|
||||||
"type": "${business.type!.name}",
|
|
||||||
"contactName": "${business.contactName}",
|
|
||||||
"contactEmail": "${business.contactEmail}",
|
|
||||||
"contactPhone": "${business.contactPhone}",
|
|
||||||
"notes": "${business.notes}",
|
|
||||||
"locationName": "${business.locationName}",
|
|
||||||
"locationAddress": "${business.locationAddress}"
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
try {
|
|
||||||
var response = await http.post(Uri.parse('$apiAddress/editbusiness'),
|
|
||||||
body: json,
|
|
||||||
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout). Please try again later';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future editListing(JobListing listing) async {
|
|
||||||
var json = '''
|
|
||||||
{
|
|
||||||
"id": ${listing.id},
|
|
||||||
"businessId": ${listing.businessId},
|
|
||||||
"name": "${listing.name}",
|
|
||||||
"description": "${listing.description.replaceAll('\n', '\\n')}",
|
|
||||||
"type": "${listing.type!.name}",
|
|
||||||
"offerType": "${listing.offerType!.name}",
|
|
||||||
"wage": "${listing.wage}",
|
|
||||||
"link": "${listing.link}"
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
try {
|
|
||||||
var response = await http.post(Uri.parse('$apiAddress/editlisting'),
|
|
||||||
body: json,
|
|
||||||
headers: {'Authorization': jwt}).timeout(const Duration(seconds: 20));
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
} on TimeoutException {
|
|
||||||
return 'Unable to connect to server (timeout). Please try again later';
|
|
||||||
} on SocketException {
|
|
||||||
return 'Unable to connect to server (socket exception). Please check your internet connection.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future signIn(String username, String password) async {
|
|
||||||
var json = '''
|
|
||||||
{
|
|
||||||
"username": "$username",
|
|
||||||
"password": "$password"
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
var response = await http.post(
|
|
||||||
Uri.parse('$apiAddress/signin'),
|
|
||||||
body: json,
|
|
||||||
);
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return response.body;
|
|
||||||
} else {
|
|
||||||
return 'Error: ${response.body}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future marinoDevLogo() async {
|
|
||||||
var response = await http.get(
|
|
||||||
Uri.parse('$apiAddress/marinodev'),
|
|
||||||
);
|
|
||||||
|
|
||||||
return response.bodyBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future getLogo(int logoId) async {
|
|
||||||
var response = await http.get(
|
|
||||||
Uri.parse('$apiAddress/logos/$logoId'),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return response.bodyBytes;
|
|
||||||
} else {
|
|
||||||
return 'Error ${response.statusCode}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,595 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:fbla_ui/shared/api_logic.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:open_filex/open_filex.dart';
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:pdf/pdf.dart';
|
|
||||||
import 'package:pdf/widgets.dart' as pw;
|
|
||||||
import 'package:printing/printing.dart';
|
|
||||||
|
|
||||||
Map<DataTypeBusiness, int> dataTypePriorityBusiness = {
|
|
||||||
DataTypeBusiness.logo: 0,
|
|
||||||
DataTypeBusiness.name: 1,
|
|
||||||
DataTypeBusiness.description: 2,
|
|
||||||
DataTypeBusiness.type: 3,
|
|
||||||
DataTypeBusiness.website: 4,
|
|
||||||
DataTypeBusiness.contactName: 5,
|
|
||||||
DataTypeBusiness.contactEmail: 6,
|
|
||||||
DataTypeBusiness.contactPhone: 7,
|
|
||||||
DataTypeBusiness.notes: 8
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<DataTypeBusiness, String> dataTypeFriendlyBusiness = {
|
|
||||||
DataTypeBusiness.logo: 'Logo',
|
|
||||||
DataTypeBusiness.name: 'Name',
|
|
||||||
DataTypeBusiness.description: 'Description',
|
|
||||||
DataTypeBusiness.type: 'Type',
|
|
||||||
DataTypeBusiness.website: 'Website',
|
|
||||||
DataTypeBusiness.contactName: 'Contact Name',
|
|
||||||
DataTypeBusiness.contactEmail: 'Contact Email',
|
|
||||||
DataTypeBusiness.contactPhone: 'Contact Phone',
|
|
||||||
DataTypeBusiness.notes: 'Notes'
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<DataTypeJob, int> dataTypePriorityJob = {
|
|
||||||
DataTypeJob.businessName: 1,
|
|
||||||
DataTypeJob.name: 2,
|
|
||||||
DataTypeJob.description: 3,
|
|
||||||
DataTypeJob.type: 4,
|
|
||||||
DataTypeJob.offerType: 5,
|
|
||||||
DataTypeJob.wage: 6,
|
|
||||||
DataTypeJob.link: 7,
|
|
||||||
};
|
|
||||||
|
|
||||||
Map<DataTypeJob, String> dataTypeFriendlyJob = {
|
|
||||||
DataTypeJob.businessName: 'Business Name',
|
|
||||||
DataTypeJob.name: 'Job Listing Name',
|
|
||||||
DataTypeJob.description: 'Description',
|
|
||||||
DataTypeJob.type: 'Job Type',
|
|
||||||
DataTypeJob.offerType: 'Offer Type',
|
|
||||||
DataTypeJob.wage: 'Wage Information',
|
|
||||||
DataTypeJob.link: 'Additional Info Link',
|
|
||||||
};
|
|
||||||
|
|
||||||
Set<DataTypeBusiness> sortDataTypesBusiness(Set<DataTypeBusiness> set) {
|
|
||||||
List<DataTypeBusiness> list = set.toList();
|
|
||||||
list.sort((a, b) {
|
|
||||||
return dataTypePriorityBusiness[a]!.compareTo(dataTypePriorityBusiness[b]!);
|
|
||||||
});
|
|
||||||
set = list.toSet();
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<DataTypeJob> sortDataTypesJob(Set<DataTypeJob> set) {
|
|
||||||
List<DataTypeJob> list = set.toList();
|
|
||||||
list.sort((a, b) {
|
|
||||||
return dataTypePriorityJob[a]!.compareTo(dataTypePriorityJob[b]!);
|
|
||||||
});
|
|
||||||
set = list.toSet();
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FilterBusinessDataTypeChips extends StatefulWidget {
|
|
||||||
final Set<DataTypeBusiness> selectedDataTypesBusiness;
|
|
||||||
|
|
||||||
const _FilterBusinessDataTypeChips({required this.selectedDataTypesBusiness});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_FilterBusinessDataTypeChips> createState() =>
|
|
||||||
_FilterBusinessDataTypeChipsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FilterBusinessDataTypeChipsState
|
|
||||||
extends State<_FilterBusinessDataTypeChips> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<Widget> chips = [];
|
|
||||||
for (var type in DataTypeBusiness.values) {
|
|
||||||
chips.add(FilterChip(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
side: BorderSide(color: Theme.of(context).colorScheme.secondary)),
|
|
||||||
label: Text(dataTypeFriendlyBusiness[type]!),
|
|
||||||
showCheckmark: false,
|
|
||||||
selected: widget.selectedDataTypesBusiness.contains(type),
|
|
||||||
onSelected: (bool selected) {
|
|
||||||
setState(() {
|
|
||||||
if (selected) {
|
|
||||||
widget.selectedDataTypesBusiness.add(type);
|
|
||||||
} else {
|
|
||||||
widget.selectedDataTypesBusiness.remove(type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return Wrap(
|
|
||||||
spacing: 6,
|
|
||||||
runSpacing: 6,
|
|
||||||
children: chips,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FilterJobDataTypeChips extends StatefulWidget {
|
|
||||||
final Set<DataTypeJob> selectedDataTypesJob;
|
|
||||||
|
|
||||||
const _FilterJobDataTypeChips({required this.selectedDataTypesJob});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_FilterJobDataTypeChips> createState() =>
|
|
||||||
_FilterJobDataTypeChipsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FilterJobDataTypeChipsState extends State<_FilterJobDataTypeChips> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<Padding> chips = [];
|
|
||||||
for (var type in DataTypeJob.values) {
|
|
||||||
chips.add(Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.only(left: 3.0, right: 3.0, bottom: 3.0, top: 3.0),
|
|
||||||
child: FilterChip(
|
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
side:
|
|
||||||
BorderSide(color: Theme.of(context).colorScheme.secondary)),
|
|
||||||
label: Text(dataTypeFriendlyJob[type]!),
|
|
||||||
showCheckmark: false,
|
|
||||||
selected: widget.selectedDataTypesJob.contains(type),
|
|
||||||
onSelected: (bool selected) {
|
|
||||||
setState(() {
|
|
||||||
if (selected) {
|
|
||||||
widget.selectedDataTypesJob.add(type);
|
|
||||||
} else {
|
|
||||||
widget.selectedDataTypesJob.remove(type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return Wrap(
|
|
||||||
spacing: 6,
|
|
||||||
runSpacing: 6,
|
|
||||||
children: chips,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> generatePDF(
|
|
||||||
{required BuildContext context,
|
|
||||||
required int documentTypeIndex,
|
|
||||||
Set<Business>? selectedBusinesses,
|
|
||||||
Set<Business>? selectedJobs}) async {
|
|
||||||
List<pw.Widget> headerColumns = [];
|
|
||||||
List<pw.TableRow> tableRows = [];
|
|
||||||
|
|
||||||
Set<DataTypeBusiness> dataTypesBusiness = {};
|
|
||||||
Set<DataTypeJob> dataTypesJob = {};
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
contentPadding: const EdgeInsets.all(16),
|
|
||||||
scrollable: true,
|
|
||||||
title: const Text('Export Settings'),
|
|
||||||
content: SizedBox(
|
|
||||||
width: 400,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: Text('Data columns you want to export:'),
|
|
||||||
),
|
|
||||||
documentTypeIndex == 0
|
|
||||||
? _FilterBusinessDataTypeChips(
|
|
||||||
selectedDataTypesBusiness: dataTypesBusiness,
|
|
||||||
)
|
|
||||||
: _FilterJobDataTypeChips(
|
|
||||||
selectedDataTypesJob: dataTypesJob)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Generate'),
|
|
||||||
onPressed: () async {
|
|
||||||
if (documentTypeIndex == 0) {
|
|
||||||
List<Business> businesses = await fetchBusinesses(
|
|
||||||
selectedBusinesses!
|
|
||||||
.map((business) => business.id)
|
|
||||||
.toList());
|
|
||||||
if (dataTypesBusiness.isEmpty) {
|
|
||||||
dataTypesBusiness.addAll(DataTypeBusiness.values);
|
|
||||||
}
|
|
||||||
dataTypesBusiness =
|
|
||||||
sortDataTypesBusiness(dataTypesBusiness);
|
|
||||||
|
|
||||||
for (Business business in businesses) {
|
|
||||||
List<pw.Widget> businessRow = [];
|
|
||||||
if (dataTypesBusiness.contains(DataTypeBusiness.logo)) {
|
|
||||||
var apiLogo = await getLogo(business.id);
|
|
||||||
if (apiLogo.runtimeType != String) {
|
|
||||||
businessRow.add(pw.Padding(
|
|
||||||
child: pw.ClipRRect(
|
|
||||||
child: pw.Image(pw.MemoryImage(apiLogo),
|
|
||||||
height: 24, width: 24),
|
|
||||||
horizontalRadius: 4,
|
|
||||||
verticalRadius: 4),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
} else {
|
|
||||||
businessRow.add(pw.Padding(
|
|
||||||
child: pw.Icon(
|
|
||||||
getPwIconFromBusinessType(business.type!),
|
|
||||||
size: 24),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (DataTypeBusiness dataType in dataTypesBusiness) {
|
|
||||||
if (dataType != DataTypeBusiness.logo) {
|
|
||||||
var currentValue =
|
|
||||||
businessValueFromDataType(business, dataType);
|
|
||||||
if (currentValue != null) {
|
|
||||||
businessRow.add(pw.Padding(
|
|
||||||
child: pw.Text(businessValueFromDataType(
|
|
||||||
business, dataType)),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
} else {
|
|
||||||
businessRow.add(pw.Container());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tableRows.add(pw.TableRow(children: businessRow));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var filter in dataTypesBusiness) {
|
|
||||||
headerColumns.add(pw.Padding(
|
|
||||||
child: pw.Text(dataTypeFriendlyBusiness[filter]!,
|
|
||||||
style: const pw.TextStyle(fontSize: 10)),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (dataTypesJob.isEmpty) {
|
|
||||||
dataTypesJob.addAll(DataTypeJob.values);
|
|
||||||
}
|
|
||||||
dataTypesJob = sortDataTypesJob(dataTypesJob);
|
|
||||||
|
|
||||||
// List<Map<String, dynamic>> nameMapping =
|
|
||||||
// await fetchBusinessNames();
|
|
||||||
|
|
||||||
for (Business business in selectedJobs!) {
|
|
||||||
for (JobListing job in business.listings!) {
|
|
||||||
List<pw.Widget> jobRow = [];
|
|
||||||
for (DataTypeJob dataType in dataTypesJob) {
|
|
||||||
switch (dataType) {
|
|
||||||
case DataTypeJob.businessName:
|
|
||||||
jobRow.add(pw.Padding(
|
|
||||||
child: pw.Text(business.name!),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
case DataTypeJob.type:
|
|
||||||
jobRow.add(pw.Padding(
|
|
||||||
child: pw.Text(getNameFromJobType(job.type!)),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
case DataTypeJob.offerType:
|
|
||||||
jobRow.add(pw.Padding(
|
|
||||||
child: pw.Text(
|
|
||||||
getNameFromOfferType(job.offerType!)),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
default:
|
|
||||||
jobRow.add(pw.Padding(
|
|
||||||
child: pw.Text(
|
|
||||||
jobValueFromDataType(job, dataType) ??
|
|
||||||
''),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
}
|
|
||||||
// if (dataType != DataTypeJob.businessName) {
|
|
||||||
// var currentValue =
|
|
||||||
// jobValueFromDataType(job, dataType);
|
|
||||||
// if (currentValue != null) {
|
|
||||||
// jobRow.add(pw.Padding(
|
|
||||||
// child: pw.Text(currentValue),
|
|
||||||
// padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
// } else {
|
|
||||||
// jobRow.add(pw.Container());
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// jobRow.add(pw.Padding(
|
|
||||||
// child: pw.Text(business.name!),
|
|
||||||
// padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
tableRows.add(pw.TableRow(children: jobRow));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var filter in dataTypesJob) {
|
|
||||||
headerColumns.add(pw.Padding(
|
|
||||||
child: pw.Text(dataTypeFriendlyJob[filter]!,
|
|
||||||
style: const pw.TextStyle(fontSize: 10)),
|
|
||||||
padding: const pw.EdgeInsets.all(4.0)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Final Generation
|
|
||||||
DateTime dateTime = DateTime.now();
|
|
||||||
String minute = '00';
|
|
||||||
if (dateTime.minute.toString().length < 2) {
|
|
||||||
minute = '0${dateTime.minute}';
|
|
||||||
} else {
|
|
||||||
minute = dateTime.minute.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
String time = dateTime.hour <= 12
|
|
||||||
? '${dateTime.hour}:${minute}AM'
|
|
||||||
: '${dateTime.hour - 12}:${minute}PM';
|
|
||||||
String fileName =
|
|
||||||
'${documentTypeIndex == 0 ? 'Business' : 'Job Listing'} Data - ${dateTime.month}-${dateTime.day}-${dateTime.year} $time.pdf';
|
|
||||||
|
|
||||||
final pdf = pw.Document();
|
|
||||||
var svg = await rootBundle.loadString('assets/MarinoDev.svg');
|
|
||||||
|
|
||||||
var themeIcon = pw.ThemeData.withFont(
|
|
||||||
base: await PdfGoogleFonts.notoSansDisplayMedium(),
|
|
||||||
icons: await PdfGoogleFonts.materialIcons());
|
|
||||||
|
|
||||||
var finalTheme = themeIcon.copyWith(
|
|
||||||
defaultTextStyle: const pw.TextStyle(fontSize: 9),
|
|
||||||
);
|
|
||||||
|
|
||||||
pdf.addPage(pw.MultiPage(
|
|
||||||
theme: finalTheme,
|
|
||||||
pageFormat: PdfPageFormat.letter,
|
|
||||||
orientation: pw.PageOrientation.landscape,
|
|
||||||
margin: const pw.EdgeInsets.all(24),
|
|
||||||
build: (pw.Context context) {
|
|
||||||
return [
|
|
||||||
pw.Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
pw.MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
pw.SvgImage(svg: svg, height: 40),
|
|
||||||
pw.Padding(
|
|
||||||
padding: const pw.EdgeInsets.all(8.0),
|
|
||||||
child: pw.Text(
|
|
||||||
'${documentTypeIndex == 0 ? 'Business' : 'Job Listing'} Datasheet',
|
|
||||||
style: pw.TextStyle(
|
|
||||||
fontSize: 32,
|
|
||||||
fontWeight: pw.FontWeight.bold)),
|
|
||||||
),
|
|
||||||
pw.Text(
|
|
||||||
'Generated on ${dateTime.month}/${dateTime.day}/${dateTime.year} at $time',
|
|
||||||
style: const pw.TextStyle(fontSize: 12),
|
|
||||||
textAlign: pw.TextAlign.right),
|
|
||||||
//
|
|
||||||
]),
|
|
||||||
pw.Table(
|
|
||||||
columnWidths: documentTypeIndex == 0
|
|
||||||
? _businessColumnSizes(dataTypesBusiness)
|
|
||||||
: _jobColumnSizes(dataTypesJob),
|
|
||||||
border: const pw.TableBorder(
|
|
||||||
bottom: pw.BorderSide(),
|
|
||||||
left: pw.BorderSide(),
|
|
||||||
right: pw.BorderSide(),
|
|
||||||
top: pw.BorderSide(),
|
|
||||||
horizontalInside: pw.BorderSide(),
|
|
||||||
verticalInside: pw.BorderSide()),
|
|
||||||
children: [
|
|
||||||
pw.TableRow(
|
|
||||||
decoration: const pw.BoxDecoration(
|
|
||||||
color: PdfColors.blue400),
|
|
||||||
children: headerColumns,
|
|
||||||
repeat: true,
|
|
||||||
),
|
|
||||||
...tableRows,
|
|
||||||
])
|
|
||||||
];
|
|
||||||
}));
|
|
||||||
|
|
||||||
Uint8List pdfBytes = await pdf.save();
|
|
||||||
|
|
||||||
if (kIsWeb) {
|
|
||||||
await Printing.sharePdf(
|
|
||||||
bytes: await pdf.save(),
|
|
||||||
filename: fileName,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
var dir = await getTemporaryDirectory();
|
|
||||||
var tempDir = dir.path;
|
|
||||||
|
|
||||||
File pdfFile = File('$tempDir/$fileName');
|
|
||||||
pdfFile.writeAsBytesSync(pdfBytes);
|
|
||||||
|
|
||||||
OpenFilex.open(pdfFile.path);
|
|
||||||
}
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<int, pw.TableColumnWidth> _businessColumnSizes(
|
|
||||||
Set<DataTypeBusiness> dataTypes) {
|
|
||||||
double space = 744.0;
|
|
||||||
List<DataTypeBusiness> sorted = sortDataTypesBusiness(dataTypes).toList();
|
|
||||||
Map<int, pw.TableColumnWidth> map = {};
|
|
||||||
|
|
||||||
if (sorted.contains(DataTypeBusiness.logo)) {
|
|
||||||
space -= 32;
|
|
||||||
map.addAll(
|
|
||||||
{sorted.indexOf(DataTypeBusiness.logo): const pw.FixedColumnWidth(32)});
|
|
||||||
}
|
|
||||||
if (sorted.contains(DataTypeBusiness.type)) {
|
|
||||||
space -= 68;
|
|
||||||
map.addAll(
|
|
||||||
{sorted.indexOf(DataTypeBusiness.type): const pw.FixedColumnWidth(68)});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.contactName)) {
|
|
||||||
space -= 72;
|
|
||||||
map.addAll({
|
|
||||||
sorted.indexOf(DataTypeBusiness.contactName):
|
|
||||||
const pw.FixedColumnWidth(72)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.contactPhone)) {
|
|
||||||
space -= 76;
|
|
||||||
map.addAll({
|
|
||||||
sorted.indexOf(DataTypeBusiness.contactPhone):
|
|
||||||
const pw.FixedColumnWidth(76)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
double leftNum = 0;
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.name)) {
|
|
||||||
leftNum += 1;
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.website)) {
|
|
||||||
leftNum += 1;
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.contactEmail)) {
|
|
||||||
leftNum += 1;
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.notes)) {
|
|
||||||
leftNum += 1;
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.description)) {
|
|
||||||
leftNum += 3;
|
|
||||||
}
|
|
||||||
leftNum = space / leftNum;
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.name)) {
|
|
||||||
map.addAll(
|
|
||||||
{sorted.indexOf(DataTypeBusiness.name): pw.FixedColumnWidth(leftNum)});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.website)) {
|
|
||||||
map.addAll({
|
|
||||||
sorted.indexOf(DataTypeBusiness.website): pw.FixedColumnWidth(leftNum)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.contactEmail)) {
|
|
||||||
map.addAll({
|
|
||||||
sorted.indexOf(DataTypeBusiness.contactEmail):
|
|
||||||
pw.FixedColumnWidth(leftNum)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.notes)) {
|
|
||||||
map.addAll(
|
|
||||||
{sorted.indexOf(DataTypeBusiness.notes): pw.FixedColumnWidth(leftNum)});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeBusiness.description)) {
|
|
||||||
map.addAll({
|
|
||||||
sorted.indexOf(DataTypeBusiness.description):
|
|
||||||
pw.FixedColumnWidth(leftNum * 3)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<int, pw.TableColumnWidth> _jobColumnSizes(Set<DataTypeJob> dataTypes) {
|
|
||||||
Map<int, pw.TableColumnWidth> map = {};
|
|
||||||
List<DataTypeJob> sortedDataTypes = sortDataTypesJob(dataTypes).toList();
|
|
||||||
|
|
||||||
if (dataTypes.contains(DataTypeJob.businessName)) {
|
|
||||||
map.addAll({
|
|
||||||
sortedDataTypes.indexOf(sortedDataTypes
|
|
||||||
.where((element) => element == DataTypeJob.businessName)
|
|
||||||
.first): const pw.FractionColumnWidth(0.2)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeJob.type)) {
|
|
||||||
map.addAll({
|
|
||||||
sortedDataTypes.indexOf(sortedDataTypes
|
|
||||||
.where((element) => element == DataTypeJob.type)
|
|
||||||
.first): const pw.FractionColumnWidth(0.1)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeJob.name)) {
|
|
||||||
map.addAll({
|
|
||||||
sortedDataTypes.indexOf(sortedDataTypes
|
|
||||||
.where((element) => element == DataTypeJob.name)
|
|
||||||
.first): const pw.FractionColumnWidth(0.2)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeJob.description)) {
|
|
||||||
map.addAll({
|
|
||||||
sortedDataTypes.indexOf(sortedDataTypes
|
|
||||||
.where((element) => element == DataTypeJob.description)
|
|
||||||
.first): const pw.FractionColumnWidth(0.3)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeJob.offerType)) {
|
|
||||||
map.addAll({
|
|
||||||
sortedDataTypes.indexOf(sortedDataTypes
|
|
||||||
.where((element) => element == DataTypeJob.offerType)
|
|
||||||
.first): const pw.FractionColumnWidth(0.1)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeJob.wage)) {
|
|
||||||
map.addAll({
|
|
||||||
sortedDataTypes.indexOf(sortedDataTypes
|
|
||||||
.where((element) => element == DataTypeJob.wage)
|
|
||||||
.first): const pw.FractionColumnWidth(0.15)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (dataTypes.contains(DataTypeJob.link)) {
|
|
||||||
map.addAll({
|
|
||||||
sortedDataTypes.indexOf(sortedDataTypes
|
|
||||||
.where((element) => element == DataTypeJob.link)
|
|
||||||
.first): const pw.FractionColumnWidth(0.2)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
dynamic businessValueFromDataType(
|
|
||||||
Business business, DataTypeBusiness dataType) {
|
|
||||||
switch (dataType) {
|
|
||||||
case DataTypeBusiness.name:
|
|
||||||
return business.name;
|
|
||||||
case DataTypeBusiness.description:
|
|
||||||
return business.description;
|
|
||||||
case DataTypeBusiness.type:
|
|
||||||
return getNameFromBusinessType(business.type!);
|
|
||||||
case DataTypeBusiness.website:
|
|
||||||
return business.website;
|
|
||||||
case DataTypeBusiness.contactName:
|
|
||||||
return business.contactName;
|
|
||||||
case DataTypeBusiness.contactEmail:
|
|
||||||
return business.contactEmail;
|
|
||||||
case DataTypeBusiness.contactPhone:
|
|
||||||
return business.contactPhone;
|
|
||||||
case DataTypeBusiness.notes:
|
|
||||||
return business.notes;
|
|
||||||
case DataTypeBusiness.logo:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dynamic jobValueFromDataType(JobListing job, DataTypeJob dataType) {
|
|
||||||
switch (dataType) {
|
|
||||||
case DataTypeJob.name:
|
|
||||||
return job.name;
|
|
||||||
case DataTypeJob.description:
|
|
||||||
return job.description;
|
|
||||||
case DataTypeJob.type:
|
|
||||||
return job.type;
|
|
||||||
case DataTypeJob.offerType:
|
|
||||||
return job.offerType;
|
|
||||||
case DataTypeJob.wage:
|
|
||||||
return job.wage;
|
|
||||||
case DataTypeJob.link:
|
|
||||||
return job.link;
|
|
||||||
case DataTypeJob.businessName:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
late String jwt;
|
|
||||||
const int widescreenWidth = 600;
|
|
||||||
bool loggedIn = false;
|
|
||||||
ThemeMode themeMode = ThemeMode.system;
|
|
||||||
@ -1,311 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:pdf/widgets.dart' as pw;
|
|
||||||
|
|
||||||
enum DataTypeBusiness {
|
|
||||||
logo,
|
|
||||||
name,
|
|
||||||
description,
|
|
||||||
type,
|
|
||||||
website,
|
|
||||||
contactName,
|
|
||||||
contactEmail,
|
|
||||||
contactPhone,
|
|
||||||
notes,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum DataTypeJob {
|
|
||||||
businessName,
|
|
||||||
name,
|
|
||||||
description,
|
|
||||||
type,
|
|
||||||
offerType,
|
|
||||||
wage,
|
|
||||||
link,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum BusinessType {
|
|
||||||
food,
|
|
||||||
shop,
|
|
||||||
outdoors,
|
|
||||||
manufacturing,
|
|
||||||
entertainment,
|
|
||||||
other,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum JobType {
|
|
||||||
retail,
|
|
||||||
customerService,
|
|
||||||
foodService,
|
|
||||||
education,
|
|
||||||
maintenance,
|
|
||||||
manufacturing,
|
|
||||||
other,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum OfferType { job, internship, apprenticeship }
|
|
||||||
|
|
||||||
class JobListing {
|
|
||||||
int? id;
|
|
||||||
int? businessId;
|
|
||||||
String name;
|
|
||||||
String description;
|
|
||||||
JobType? type;
|
|
||||||
OfferType? offerType;
|
|
||||||
String? wage;
|
|
||||||
String? link;
|
|
||||||
|
|
||||||
JobListing({
|
|
||||||
this.id,
|
|
||||||
this.businessId,
|
|
||||||
required this.name,
|
|
||||||
required this.description,
|
|
||||||
this.type,
|
|
||||||
this.offerType,
|
|
||||||
this.wage,
|
|
||||||
this.link,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory JobListing.copy(JobListing input) {
|
|
||||||
return JobListing(
|
|
||||||
id: input.id,
|
|
||||||
businessId: input.businessId,
|
|
||||||
name: input.name,
|
|
||||||
description: input.description,
|
|
||||||
type: input.type,
|
|
||||||
offerType: input.offerType,
|
|
||||||
wage: input.wage,
|
|
||||||
link: input.link,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Business {
|
|
||||||
int id;
|
|
||||||
String? name;
|
|
||||||
String? description;
|
|
||||||
BusinessType? type;
|
|
||||||
String? website;
|
|
||||||
String? contactName;
|
|
||||||
String? contactEmail;
|
|
||||||
String? contactPhone;
|
|
||||||
String? notes;
|
|
||||||
String locationName;
|
|
||||||
String? locationAddress;
|
|
||||||
List<JobListing>? listings;
|
|
||||||
|
|
||||||
Business(
|
|
||||||
{required this.id,
|
|
||||||
required this.name,
|
|
||||||
required this.description,
|
|
||||||
this.website,
|
|
||||||
this.type,
|
|
||||||
this.contactName,
|
|
||||||
this.contactEmail,
|
|
||||||
this.contactPhone,
|
|
||||||
this.notes,
|
|
||||||
required this.locationName,
|
|
||||||
this.locationAddress,
|
|
||||||
this.listings});
|
|
||||||
|
|
||||||
factory Business.fromJson(Map<String, dynamic> json) {
|
|
||||||
List<JobListing>? listings;
|
|
||||||
if (json['listings'] != null) {
|
|
||||||
listings = [];
|
|
||||||
for (int i = 0; i < json['listings'].length; i++) {
|
|
||||||
listings.add(JobListing(
|
|
||||||
id: json['listings'][i]['id'],
|
|
||||||
businessId: json['listings'][i]['businessId'],
|
|
||||||
name: json['listings'][i]['name'],
|
|
||||||
description: json['listings'][i]['description'],
|
|
||||||
type: JobType.values.byName(json['listings'][i]['type']),
|
|
||||||
wage: json['listings'][i]['wage'],
|
|
||||||
link: json['listings'][i]['link'],
|
|
||||||
offerType:
|
|
||||||
OfferType.values.byName(json['listings'][i]['offerType'])));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Business(
|
|
||||||
id: json['id'],
|
|
||||||
name: json['name'],
|
|
||||||
description: json['description'],
|
|
||||||
type: json['type'] != null
|
|
||||||
? BusinessType.values.byName(json['type'])
|
|
||||||
: null,
|
|
||||||
website: json['website'],
|
|
||||||
contactName: json['contactName'],
|
|
||||||
contactEmail: json['contactEmail'],
|
|
||||||
contactPhone: json['contactPhone'],
|
|
||||||
notes: json['notes'],
|
|
||||||
locationName: json['locationName'],
|
|
||||||
locationAddress: json['locationAddress'],
|
|
||||||
listings: listings);
|
|
||||||
}
|
|
||||||
|
|
||||||
factory Business.copy(Business input) {
|
|
||||||
return Business(
|
|
||||||
id: input.id,
|
|
||||||
name: input.name,
|
|
||||||
description: input.description,
|
|
||||||
website: input.website,
|
|
||||||
contactName: input.contactName,
|
|
||||||
contactEmail: input.contactEmail,
|
|
||||||
contactPhone: input.contactPhone,
|
|
||||||
notes: input.notes,
|
|
||||||
locationName: input.locationName,
|
|
||||||
locationAddress: input.locationAddress,
|
|
||||||
listings: input.listings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IconData getIconFromBusinessType(BusinessType type) {
|
|
||||||
switch (type) {
|
|
||||||
case BusinessType.food:
|
|
||||||
return Icons.restaurant;
|
|
||||||
case BusinessType.shop:
|
|
||||||
return Icons.store;
|
|
||||||
case BusinessType.outdoors:
|
|
||||||
return Icons.forest;
|
|
||||||
case BusinessType.manufacturing:
|
|
||||||
return Icons.factory;
|
|
||||||
case BusinessType.entertainment:
|
|
||||||
return Icons.live_tv;
|
|
||||||
case BusinessType.other:
|
|
||||||
return Icons.business;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IconData getIconFromJobType(JobType type) {
|
|
||||||
switch (type) {
|
|
||||||
case JobType.retail:
|
|
||||||
return Icons.shopping_bag;
|
|
||||||
case JobType.customerService:
|
|
||||||
return Icons.support_agent;
|
|
||||||
case JobType.foodService:
|
|
||||||
return Icons.restaurant;
|
|
||||||
case JobType.education:
|
|
||||||
return Icons.school;
|
|
||||||
case JobType.maintenance:
|
|
||||||
return Icons.handyman;
|
|
||||||
case JobType.manufacturing:
|
|
||||||
return Icons.factory;
|
|
||||||
case JobType.other:
|
|
||||||
return Icons.work;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pw.IconData getPwIconFromBusinessType(BusinessType type) {
|
|
||||||
switch (type) {
|
|
||||||
case BusinessType.food:
|
|
||||||
return const pw.IconData(0xe56c);
|
|
||||||
case BusinessType.shop:
|
|
||||||
return const pw.IconData(0xea12);
|
|
||||||
case BusinessType.outdoors:
|
|
||||||
return const pw.IconData(0xea99);
|
|
||||||
case BusinessType.manufacturing:
|
|
||||||
return const pw.IconData(0xebbc);
|
|
||||||
case BusinessType.entertainment:
|
|
||||||
return const pw.IconData(0xe639);
|
|
||||||
case BusinessType.other:
|
|
||||||
return const pw.IconData(0xe0af);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pw.IconData getPwIconFromJobType(JobType type) {
|
|
||||||
switch (type) {
|
|
||||||
case JobType.retail:
|
|
||||||
return const pw.IconData(0xf1cc);
|
|
||||||
case JobType.customerService:
|
|
||||||
return const pw.IconData(0xf0e2);
|
|
||||||
case JobType.foodService:
|
|
||||||
return const pw.IconData(0xe56c);
|
|
||||||
case JobType.education:
|
|
||||||
return const pw.IconData(0xe80c);
|
|
||||||
case JobType.maintenance:
|
|
||||||
return const pw.IconData(0xf10b);
|
|
||||||
case JobType.manufacturing:
|
|
||||||
return const pw.IconData(0xebbc);
|
|
||||||
case JobType.other:
|
|
||||||
return const pw.IconData(0xe8f9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String getNameFromBusinessType(BusinessType type) {
|
|
||||||
switch (type) {
|
|
||||||
case BusinessType.food:
|
|
||||||
return 'Food Related';
|
|
||||||
case BusinessType.shop:
|
|
||||||
return 'Shops';
|
|
||||||
case BusinessType.outdoors:
|
|
||||||
return 'Outdoors';
|
|
||||||
case BusinessType.manufacturing:
|
|
||||||
return 'Manufacturing';
|
|
||||||
case BusinessType.entertainment:
|
|
||||||
return 'Entertainment';
|
|
||||||
case BusinessType.other:
|
|
||||||
return 'Other';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String getNameFromJobType(JobType type) {
|
|
||||||
switch (type) {
|
|
||||||
case JobType.retail:
|
|
||||||
return 'Retail';
|
|
||||||
case JobType.customerService:
|
|
||||||
return 'Customer Service';
|
|
||||||
case JobType.foodService:
|
|
||||||
return 'Food Service';
|
|
||||||
case JobType.education:
|
|
||||||
return 'Education';
|
|
||||||
case JobType.maintenance:
|
|
||||||
return 'Maintenance';
|
|
||||||
case JobType.manufacturing:
|
|
||||||
return 'Manufacturing';
|
|
||||||
case JobType.other:
|
|
||||||
return 'Other';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String getNameFromOfferType(OfferType type) {
|
|
||||||
switch (type) {
|
|
||||||
case OfferType.job:
|
|
||||||
return 'Job';
|
|
||||||
case OfferType.internship:
|
|
||||||
return 'Internship';
|
|
||||||
case OfferType.apprenticeship:
|
|
||||||
return 'Apprenticeship';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String getLetterFromOfferType(OfferType type) {
|
|
||||||
switch (type) {
|
|
||||||
case OfferType.job:
|
|
||||||
return 'J';
|
|
||||||
case OfferType.internship:
|
|
||||||
return 'I';
|
|
||||||
case OfferType.apprenticeship:
|
|
||||||
return 'A';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getColorFromOfferType(OfferType type) {
|
|
||||||
switch (type) {
|
|
||||||
case OfferType.job:
|
|
||||||
return Colors.blue;
|
|
||||||
case OfferType.internship:
|
|
||||||
return Colors.green.shade800;
|
|
||||||
case OfferType.apprenticeship:
|
|
||||||
return Colors.red;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IconData getIconFromThemeMode(ThemeMode theme) {
|
|
||||||
switch (theme) {
|
|
||||||
case ThemeMode.dark:
|
|
||||||
return Icons.dark_mode;
|
|
||||||
case ThemeMode.light:
|
|
||||||
return Icons.light_mode;
|
|
||||||
case ThemeMode.system:
|
|
||||||
return Icons.brightness_4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,409 +0,0 @@
|
|||||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
|
||||||
import 'package:fbla_ui/pages/signin_page.dart';
|
|
||||||
import 'package:fbla_ui/shared/global_vars.dart';
|
|
||||||
import 'package:fbla_ui/shared/utils.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
class BusinessSearchBar extends StatefulWidget {
|
|
||||||
final String searchTextHint;
|
|
||||||
final Widget filterIconButton;
|
|
||||||
final void Function(String) setSearchCallback;
|
|
||||||
|
|
||||||
const BusinessSearchBar(
|
|
||||||
{super.key,
|
|
||||||
required this.setSearchCallback,
|
|
||||||
required this.searchTextHint,
|
|
||||||
required this.filterIconButton});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<BusinessSearchBar> createState() => _BusinessSearchBarState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _BusinessSearchBarState extends State<BusinessSearchBar> {
|
|
||||||
TextEditingController controller = TextEditingController();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SizedBox(
|
|
||||||
width: 450,
|
|
||||||
height: 50,
|
|
||||||
child: SearchBar(
|
|
||||||
hintText: widget.searchTextHint,
|
|
||||||
controller: controller,
|
|
||||||
backgroundColor: WidgetStateProperty.resolveWith((notNeeded) {
|
|
||||||
return Theme.of(context).colorScheme.surfaceContainer;
|
|
||||||
}),
|
|
||||||
onChanged: (query) {
|
|
||||||
widget.setSearchCallback(query);
|
|
||||||
},
|
|
||||||
leading: const Padding(
|
|
||||||
padding: EdgeInsets.only(left: 8.0),
|
|
||||||
child: Icon(Icons.search),
|
|
||||||
),
|
|
||||||
trailing: [
|
|
||||||
if (controller.text != '')
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.clear),
|
|
||||||
onPressed: () {
|
|
||||||
controller.text = '';
|
|
||||||
widget.setSearchCallback('');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
widget.filterIconButton
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FilterChips extends StatefulWidget {
|
|
||||||
final Set<JobType>? selectedJobChips;
|
|
||||||
final Set<BusinessType>? selectedBusinessChips;
|
|
||||||
|
|
||||||
const FilterChips(
|
|
||||||
{super.key, this.selectedJobChips, this.selectedBusinessChips});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<FilterChips> createState() => _FilterChipsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FilterChipsState extends State<FilterChips> {
|
|
||||||
List<Padding> filterChips() {
|
|
||||||
List<Padding> chips = [];
|
|
||||||
|
|
||||||
if (widget.selectedJobChips != null) {
|
|
||||||
for (var type in JobType.values) {
|
|
||||||
chips.add(Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 4.0, right: 4.0),
|
|
||||||
child: FilterChip(
|
|
||||||
showCheckmark: false,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20)),
|
|
||||||
label: Text(getNameFromJobType(type)),
|
|
||||||
selected: widget.selectedJobChips!.contains(type),
|
|
||||||
onSelected: (bool selected) {
|
|
||||||
setState(() {
|
|
||||||
if (selected) {
|
|
||||||
widget.selectedJobChips!.add(type);
|
|
||||||
} else {
|
|
||||||
widget.selectedJobChips!.remove(type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else if (widget.selectedBusinessChips != null) {
|
|
||||||
for (var type in BusinessType.values) {
|
|
||||||
chips.add(Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 4.0, right: 4.0),
|
|
||||||
child: FilterChip(
|
|
||||||
showCheckmark: false,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20)),
|
|
||||||
label: Text(getNameFromBusinessType(type)),
|
|
||||||
selected: widget.selectedBusinessChips!.contains(type),
|
|
||||||
onSelected: (bool selected) {
|
|
||||||
setState(() {
|
|
||||||
if (selected) {
|
|
||||||
widget.selectedBusinessChips!.add(type);
|
|
||||||
} else {
|
|
||||||
widget.selectedBusinessChips!.remove(type);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return chips;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Wrap(
|
|
||||||
children: filterChips(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MainSliverAppBar extends StatefulWidget {
|
|
||||||
final bool widescreen;
|
|
||||||
final Widget filterIconButton;
|
|
||||||
final void Function(String) setSearch;
|
|
||||||
final void Function() themeCallback;
|
|
||||||
final void Function() generatePDF;
|
|
||||||
final void Function(bool) updateLoggedIn;
|
|
||||||
final String searchHintText;
|
|
||||||
|
|
||||||
const MainSliverAppBar({
|
|
||||||
super.key,
|
|
||||||
required this.widescreen,
|
|
||||||
required this.setSearch,
|
|
||||||
required this.searchHintText,
|
|
||||||
required this.themeCallback,
|
|
||||||
required this.filterIconButton,
|
|
||||||
required this.updateLoggedIn,
|
|
||||||
required this.generatePDF,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MainSliverAppBar> createState() => _MainSliverAppBarState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MainSliverAppBarState extends State<MainSliverAppBar> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SliverAppBar(
|
|
||||||
title: widget.widescreen
|
|
||||||
? Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Flexible(
|
|
||||||
child: BusinessSearchBar(
|
|
||||||
setSearchCallback: widget.setSearch,
|
|
||||||
searchTextHint: widget.searchHintText,
|
|
||||||
filterIconButton: widget.filterIconButton,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
// const PreferredSize(
|
|
||||||
// preferredSize: Size(144, 0), child: SizedBox())
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: const Text('Job Link'),
|
|
||||||
toolbarHeight: 70,
|
|
||||||
stretch: false,
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
pinned: true,
|
|
||||||
// floating: true,
|
|
||||||
scrolledUnderElevation: 0,
|
|
||||||
centerTitle: !widget.widescreen,
|
|
||||||
expandedHeight: widget.widescreen ? 70 : 120,
|
|
||||||
bottom: _getBottom(widget.widescreen),
|
|
||||||
leading: !widget.widescreen
|
|
||||||
? IconButton(
|
|
||||||
icon: Icon(getIconFromThemeMode(themeMode)),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
widget.themeCallback();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.file_download_outlined),
|
|
||||||
onPressed: widget.generatePDF,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.help),
|
|
||||||
onPressed: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('About'),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
content: SizedBox(
|
|
||||||
width: 500,
|
|
||||||
child: IntrinsicHeight(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
'Welcome to my FBLA 2024 Coding and Programming submission!\n\n'
|
|
||||||
'MarinoDev Job Link aims to provide comprehensive details of businesses and community partners'
|
|
||||||
' for Waukesha West High School\'s Career and Technical Education Department.\n\n'),
|
|
||||||
MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
child: const Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text('Git Repo:'),
|
|
||||||
Text(
|
|
||||||
'https://git.marinodev.com/MarinoDev/FBLA24\n',
|
|
||||||
style: TextStyle(color: Colors.blue)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
launchUrl(Uri.https('git.marinodev.com',
|
|
||||||
'/MarinoDev/FBLA24'));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MouseRegion(
|
|
||||||
cursor: SystemMouseCursors.click,
|
|
||||||
child: GestureDetector(
|
|
||||||
child: const Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text('Please direct any questions to'),
|
|
||||||
Text('drake@marinodev.com',
|
|
||||||
style: TextStyle(color: Colors.blue)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
launchUrl(
|
|
||||||
Uri.parse('mailto:drake@marinodev.com'));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('OK'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 8.0),
|
|
||||||
child: IconButton(
|
|
||||||
icon: loggedIn
|
|
||||||
? const Icon(Icons.account_circle)
|
|
||||||
: const Icon(Icons.login),
|
|
||||||
onPressed: () {
|
|
||||||
if (loggedIn) {
|
|
||||||
var payload = JWT.decode(jwt).payload;
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
title: Text('Hi, ${payload['username']}!'),
|
|
||||||
content: Text(
|
|
||||||
'You are logged in as an admin with username ${payload['username']}.'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Logout'),
|
|
||||||
onPressed: () async {
|
|
||||||
final prefs =
|
|
||||||
await SharedPreferences.getInstance();
|
|
||||||
prefs.setBool('rememberMe', false);
|
|
||||||
prefs.setString('username', '');
|
|
||||||
prefs.setString('password', '');
|
|
||||||
|
|
||||||
widget.updateLoggedIn(false);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
SignInPage(refreshAccount: widget.updateLoggedIn)));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
PreferredSizeWidget? _getBottom(bool widescreen) {
|
|
||||||
if (!widescreen) {
|
|
||||||
return PreferredSize(
|
|
||||||
preferredSize: const Size.fromHeight(0),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 70,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: BusinessSearchBar(
|
|
||||||
filterIconButton: widget.filterIconButton,
|
|
||||||
setSearchCallback: widget.setSearch,
|
|
||||||
searchTextHint: widget.searchHintText,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ContactInformationCard extends StatelessWidget {
|
|
||||||
final Business business;
|
|
||||||
|
|
||||||
ContactInformationCard({super.key, required this.business});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Card(
|
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16.0, top: 8.0),
|
|
||||||
child: Text(
|
|
||||||
business.contactName!,
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 20, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (business.contactPhone != null)
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.phone),
|
|
||||||
title: Text(business.contactPhone!),
|
|
||||||
onTap: () {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
title: Text('Contact ${business.contactName}'),
|
|
||||||
content: Text(
|
|
||||||
'Would you like to call or text ${business.contactName}?'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Text'),
|
|
||||||
onPressed: () {
|
|
||||||
launchUrl(
|
|
||||||
Uri.parse('sms:${business.contactPhone}'));
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Call'),
|
|
||||||
onPressed: () async {
|
|
||||||
launchUrl(
|
|
||||||
Uri.parse('tel:${business.contactPhone}'));
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (business.contactEmail != null)
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.email),
|
|
||||||
title: Text(business.contactEmail!),
|
|
||||||
onTap: () {
|
|
||||||
launchUrl(Uri.parse('mailto:${business.contactEmail}'));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -41,7 +41,7 @@ endif ()
|
|||||||
# of modifying this function.
|
# of modifying this function.
|
||||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||||
target_compile_features(${TARGET} PUBLIC cxx_std_14)
|
target_compile_features(${TARGET} PUBLIC cxx_std_14)
|
||||||
target_compile_options(${TARGET} PRIVATE -Wall) # removed -Werror to avoid error from libraries on unused vars
|
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@ -7,16 +7,12 @@
|
|||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <printing/printing_plugin.h>
|
#include <printing/printing_plugin.h>
|
||||||
#include <rive_common/rive_plugin.h>
|
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) printing_registrar =
|
g_autoptr(FlPluginRegistrar) printing_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "PrintingPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "PrintingPlugin");
|
||||||
printing_plugin_register_with_registrar(printing_registrar);
|
printing_plugin_register_with_registrar(printing_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) rive_common_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "RivePlugin");
|
|
||||||
rive_plugin_register_with_registrar(rive_common_registrar);
|
|
||||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
printing
|
printing
|
||||||
rive_common
|
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: archive
|
name: archive
|
||||||
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
|
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.6.1"
|
version: "3.4.10"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -29,10 +29,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: barcode
|
name: barcode
|
||||||
sha256: ab180ce22c6555d77d45f0178a523669db67f95856e3378259ef2ffeb43e6003
|
sha256: "91b143666f7bb13636f716b6d4e412e372ab15ff7969799af8c9e30a382e9385"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.8"
|
version: "2.2.6"
|
||||||
bidi:
|
bidi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -93,18 +93,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cupertino_icons
|
name: cupertino_icons
|
||||||
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
|
sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.8"
|
version: "1.0.6"
|
||||||
dart_jsonwebtoken:
|
dart_jsonwebtoken:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: dart_jsonwebtoken
|
name: dart_jsonwebtoken
|
||||||
sha256: "346e9a21e4bf6e6a431e19ece00ebb2e3668e1e339cabdf6f46d18d88692a848"
|
sha256: "40dc3a4788c02a44bc97ea0c8c4a078ae58c9a45acc2312ee6a689b0e8f5b5b9"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.14.0"
|
version: "2.13.0"
|
||||||
ed25519_edwards:
|
ed25519_edwards:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -204,10 +204,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: image
|
name: image
|
||||||
sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8"
|
sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.2.0"
|
version: "4.1.7"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -220,26 +220,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker
|
name: leak_tracker
|
||||||
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
|
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.0.4"
|
version: "10.0.0"
|
||||||
leak_tracker_flutter_testing:
|
leak_tracker_flutter_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_flutter_testing
|
name: leak_tracker_flutter_testing
|
||||||
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
|
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.3"
|
version: "2.0.1"
|
||||||
leak_tracker_testing:
|
leak_tracker_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_testing
|
name: leak_tracker_testing
|
||||||
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "2.0.1"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -268,10 +268,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
|
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.12.0"
|
version: "1.11.0"
|
||||||
open_filex:
|
open_filex:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -300,26 +300,26 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: path_provider
|
name: path_provider
|
||||||
sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161
|
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.3"
|
version: "2.1.2"
|
||||||
path_provider_android:
|
path_provider_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_android
|
name: path_provider_android
|
||||||
sha256: bca87b0165ffd7cdb9cad8edd22d18d2201e886d9a9f19b4fb3452ea7df3a72a
|
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.6"
|
version: "2.2.2"
|
||||||
path_provider_foundation:
|
path_provider_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_foundation
|
name: path_provider_foundation
|
||||||
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
|
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.3.2"
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -348,18 +348,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: pdf
|
name: pdf
|
||||||
sha256: "81d5522bddc1ef5c28e8f0ee40b71708761753c163e0c93a40df56fd515ea0f0"
|
sha256: "243f05342fc0bdf140eba5b069398985cdbdd3dbb1d776cf43d5ea29cc570ba6"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.11.0"
|
version: "3.10.8"
|
||||||
pdf_widget_wrapper:
|
pdf_widget_wrapper:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pdf_widget_wrapper
|
name: pdf_widget_wrapper
|
||||||
sha256: c930860d987213a3d58c7ec3b7ecf8085c3897f773e8dc23da9cae60a5d6d0f5
|
sha256: "9c3ca36e5000c9682d52bbdc486867ba7c5ee4403d1a5d6d03ed72157753377b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.3"
|
||||||
petitparser:
|
petitparser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -372,10 +372,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: platform
|
name: platform
|
||||||
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
|
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.5"
|
version: "3.1.4"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -388,18 +388,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pointycastle
|
name: pointycastle
|
||||||
sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
|
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.9.1"
|
version: "3.7.4"
|
||||||
printing:
|
printing:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: printing
|
name: printing
|
||||||
sha256: cc4b256a5a89d5345488e3318897b595867f5181b8c5ed6fc63bfa5f2044aec3
|
sha256: "1c99cab90ebcc1fff65831d264627d5b529359d563e53f33ab9b8117f2d280bc"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.13.1"
|
version: "5.12.0"
|
||||||
qr:
|
qr:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -412,42 +412,42 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: rive
|
name: rive
|
||||||
sha256: "0342c9cd3c83ceeee4ad9246b98d628a2e9abd9d615acf69fa81fbbcf84a36ae"
|
sha256: ec44b6cf7341e21727c4b0e762f4ac82f9a45f7e52df3ebad2d1289a726fbaaf
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.13.8"
|
version: "0.13.1"
|
||||||
rive_common:
|
rive_common:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: rive_common
|
name: rive_common
|
||||||
sha256: "3fe76ba4680787741688ee393e47b63417e8643816795e4eac01021683af1d84"
|
sha256: "0f070bc0e764c570abd8b34d744ef30d1292bd4051f2e0951bbda755875fce6a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.9"
|
version: "0.3.3"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: shared_preferences
|
name: shared_preferences
|
||||||
sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180
|
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.3"
|
version: "2.2.2"
|
||||||
shared_preferences_android:
|
shared_preferences_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_android
|
name: shared_preferences_android
|
||||||
sha256: "93d0ec9dd902d85f326068e6a899487d1f65ffcd5798721a95330b26c8131577"
|
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.3"
|
version: "2.2.1"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_foundation
|
name: shared_preferences_foundation
|
||||||
sha256: "0a8a893bf4fd1152f93fec03a415d11c27c74454d96e2318a7ac38dd18683ab7"
|
sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.3.5"
|
||||||
shared_preferences_linux:
|
shared_preferences_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -537,10 +537,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
|
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.0"
|
version: "0.6.1"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -553,26 +553,26 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: url_launcher
|
name: url_launcher
|
||||||
sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
|
sha256: "0ecc004c62fd3ed36a2ffcbe0dd9700aee63bd7532d0b642a488b1ec310f492e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.0"
|
version: "6.2.5"
|
||||||
url_launcher_android:
|
url_launcher_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_android
|
name: url_launcher_android
|
||||||
sha256: ceb2625f0c24ade6ef6778d1de0b2e44f2db71fded235eb52295247feba8c5cf
|
sha256: d4ed0711849dd8e33eb2dd69c25db0d0d3fdc37e0a62e629fe32f57a22db2745
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.3"
|
version: "6.3.0"
|
||||||
url_launcher_ios:
|
url_launcher_ios:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_ios
|
name: url_launcher_ios
|
||||||
sha256: "7068716403343f6ba4969b4173cbf3b84fc768042124bc2c011e5d782b24fe89"
|
sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.0"
|
version: "6.2.5"
|
||||||
url_launcher_linux:
|
url_launcher_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -585,10 +585,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_macos
|
name: url_launcher_macos
|
||||||
sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de"
|
sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.2.0"
|
version: "3.1.0"
|
||||||
url_launcher_platform_interface:
|
url_launcher_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -601,10 +601,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_web
|
name: url_launcher_web
|
||||||
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
|
sha256: "3692a459204a33e04bc94f5fb91158faf4f2c8903281ddd82915adecdb1a901d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.1"
|
version: "2.3.0"
|
||||||
url_launcher_windows:
|
url_launcher_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -633,10 +633,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
|
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "14.2.1"
|
version: "13.0.0"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -649,10 +649,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4
|
sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.5.1"
|
version: "5.3.0"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -670,5 +670,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "6.5.0"
|
version: "6.5.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.4.0 <4.0.0"
|
dart: ">=3.3.0 <4.0.0"
|
||||||
flutter: ">=3.22.0"
|
flutter: ">=3.19.0"
|
||||||
|
|||||||
@ -73,8 +73,6 @@ flutter:
|
|||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
assets:
|
assets:
|
||||||
- assets/mdev_triangle_loading.riv
|
- assets/mdev_triangle_loading.riv
|
||||||
- assets/MarinoDev.svg
|
|
||||||
- assets/Triangle256.png
|
|
||||||
# - images/a_dot_burr.jpeg
|
# - images/a_dot_burr.jpeg
|
||||||
# - images/a_dot_ham.jpeg
|
# - images/a_dot_ham.jpeg
|
||||||
|
|
||||||
@ -103,12 +101,3 @@ flutter:
|
|||||||
#
|
#
|
||||||
# For details regarding fonts from package dependencies,
|
# For details regarding fonts from package dependencies,
|
||||||
# see https://flutter.dev/custom-fonts/#from-packages
|
# see https://flutter.dev/custom-fonts/#from-packages
|
||||||
|
|
||||||
msix_config:
|
|
||||||
display_name: Job Link
|
|
||||||
publisher_display_name: MarinoDev
|
|
||||||
identity_name: com.marinodev.joblink
|
|
||||||
msix_version: 0.1.0.0
|
|
||||||
logo_path: C:\Users\Drake Marino\Code\FBLA24\fbla24\fbla_ui\windows\windows_logo.png
|
|
||||||
capabilities: internetClient
|
|
||||||
install_certificate: true
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
FlutterWindow window(project);
|
FlutterWindow window(project);
|
||||||
Win32Window::Point origin(10, 10);
|
Win32Window::Point origin(10, 10);
|
||||||
Win32Window::Size size(1280, 720);
|
Win32Window::Size size(1280, 720);
|
||||||
if (!window.Create(L"Job Link", origin, size)) {
|
if (!window.Create(L"fbla_ui", origin, size)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
window.SetQuitOnClose(true);
|
window.SetQuitOnClose(true);
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 33 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
Loading…
Reference in New Issue
Block a user