v0.2.0 beta - Major screen changes
This commit is contained in:
@@ -0,0 +1,385 @@
|
||||
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';
|
||||
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({List<JobType>? typeFilters}) async {
|
||||
try {
|
||||
String? typeString =
|
||||
typeFilters?.map((jobType) => jobType.name).toList().join(',');
|
||||
Uri uri =
|
||||
Uri.parse('$apiAddress/businessdata/overview/jobs?filters=$typeString');
|
||||
if (typeFilters == null || typeFilters.isEmpty) {
|
||||
uri = Uri.parse('$apiAddress/businessdata/overview/jobs');
|
||||
}
|
||||
var response = await http.get(uri).timeout(const Duration(seconds: 20));
|
||||
if (response.statusCode == 200) {
|
||||
var decodedResponse = json.decode(response.body);
|
||||
Map<JobType, List<Business>> groupedBusinesses = {};
|
||||
|
||||
for (String stringType in decodedResponse.keys) {
|
||||
List<Business> businesses = [];
|
||||
|
||||
for (Map<String, dynamic> map in decodedResponse[stringType]) {
|
||||
Business business = Business.fromJson(map);
|
||||
businesses.add(business);
|
||||
}
|
||||
|
||||
groupedBusinesses
|
||||
.addAll({JobType.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 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')}",
|
||||
"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}",
|
||||
"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'),
|
||||
);
|
||||
|
||||
// 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}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
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';
|
||||
|
||||
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<Padding> chips = [];
|
||||
for (var type in DataTypeBusiness.values) {
|
||||
chips.add(Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 3.0, right: 3.0, bottom: 3.0, top: 3.0),
|
||||
child: 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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
title: const Text('Export Settings'),
|
||||
content: SizedBox(
|
||||
width: 400,
|
||||
height: 200,
|
||||
child: Column(
|
||||
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) {
|
||||
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 (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 += 2;
|
||||
}
|
||||
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 * 2)
|
||||
});
|
||||
}
|
||||
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.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.4)
|
||||
});
|
||||
}
|
||||
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 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.wage:
|
||||
return job.wage;
|
||||
case DataTypeJob.link:
|
||||
return job.link;
|
||||
case DataTypeJob.businessName:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
late String jwt;
|
||||
const int widescreenWidth = 600;
|
||||
bool loggedIn = false;
|
||||
ThemeMode themeMode = ThemeMode.system;
|
||||
@@ -0,0 +1,300 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
|
||||
enum DataTypeBusiness {
|
||||
logo,
|
||||
name,
|
||||
description,
|
||||
website,
|
||||
contactName,
|
||||
contactEmail,
|
||||
contactPhone,
|
||||
notes,
|
||||
type,
|
||||
}
|
||||
|
||||
enum DataTypeJob {
|
||||
businessName,
|
||||
name,
|
||||
description,
|
||||
wage,
|
||||
link,
|
||||
}
|
||||
|
||||
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.wage: 4,
|
||||
DataTypeJob.link: 5,
|
||||
};
|
||||
|
||||
Map<DataTypeJob, String> dataTypeFriendlyJob = {
|
||||
DataTypeJob.businessName: 'Business Name',
|
||||
DataTypeJob.name: 'Job Listing Name',
|
||||
DataTypeJob.description: 'Description',
|
||||
DataTypeJob.wage: 'Wage',
|
||||
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;
|
||||
}
|
||||
|
||||
enum BusinessType {
|
||||
food,
|
||||
shop,
|
||||
outdoors,
|
||||
manufacturing,
|
||||
entertainment,
|
||||
other,
|
||||
}
|
||||
|
||||
enum JobType { cashier, server, mechanic, other }
|
||||
|
||||
class JobListing {
|
||||
int? id;
|
||||
int? businessId;
|
||||
String name;
|
||||
String description;
|
||||
JobType? type;
|
||||
String? wage;
|
||||
String? link;
|
||||
|
||||
JobListing(
|
||||
{this.id,
|
||||
this.businessId,
|
||||
required this.name,
|
||||
required this.description,
|
||||
this.type,
|
||||
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,
|
||||
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,
|
||||
required 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']));
|
||||
}
|
||||
}
|
||||
|
||||
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.cashier:
|
||||
return Icons.shopping_bag;
|
||||
case JobType.server:
|
||||
return Icons.restaurant;
|
||||
case JobType.mechanic:
|
||||
return Icons.construction;
|
||||
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.cashier:
|
||||
return const pw.IconData(0xf1cc);
|
||||
case JobType.server:
|
||||
return const pw.IconData(0xe56c);
|
||||
case JobType.mechanic:
|
||||
return const pw.IconData(0xea3c);
|
||||
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.cashier:
|
||||
return 'Cashier';
|
||||
case JobType.server:
|
||||
return 'Server';
|
||||
case JobType.mechanic:
|
||||
return 'Mechanic';
|
||||
case JobType.other:
|
||||
return 'Other';
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,821 @@
|
||||
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 BusinessDisplayPanel extends StatefulWidget {
|
||||
// final Map<JobType, List<Business>>? jobGroupedBusinesses;
|
||||
// final Map<BusinessType, List<Business>>? businessGroupedBusinesses;
|
||||
// final bool widescreen;
|
||||
// final Set<Business>? selectedBusinesses;
|
||||
//
|
||||
// const BusinessDisplayPanel(
|
||||
// {super.key,
|
||||
// this.jobGroupedBusinesses,
|
||||
// this.businessGroupedBusinesses,
|
||||
// required this.widescreen,
|
||||
// this.selectedBusinesses});
|
||||
//
|
||||
// @override
|
||||
// State<BusinessDisplayPanel> createState() => _BusinessDisplayPanelState();
|
||||
// }
|
||||
//
|
||||
// class _BusinessDisplayPanelState extends State<BusinessDisplayPanel> {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// if ((widget.businessGroupedBusinesses?.keys ?? <BusinessType>[]).isEmpty &&
|
||||
// (widget.jobGroupedBusinesses?.keys ?? <JobType>[]).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 = [];
|
||||
// if (widget.jobGroupedBusinesses != null) {
|
||||
// for (JobType jobType in widget.jobGroupedBusinesses!.keys) {
|
||||
// headers.add(BusinessHeader(
|
||||
// jobType: jobType,
|
||||
// widescreen: widget.widescreen,
|
||||
// // selectable: widget.selectable,
|
||||
// selectedBusinesses: widget.selectedBusinesses,
|
||||
// // updateSelectedBusinessesCallback:
|
||||
// // widget.updateSelectedBusinessesCallback,
|
||||
// businesses: widget.jobGroupedBusinesses![jobType]!));
|
||||
// }
|
||||
// headers.sort((a, b) => a.jobType!.index.compareTo(b.jobType!.index));
|
||||
// return MultiSliver(children: headers);
|
||||
// } else if (widget.businessGroupedBusinesses != null) {
|
||||
// for (BusinessType businessType
|
||||
// in widget.businessGroupedBusinesses!.keys) {
|
||||
// headers.add(BusinessHeader(
|
||||
// businessType: businessType,
|
||||
// widescreen: widget.widescreen,
|
||||
// selectedBusinesses: widget.selectedBusinesses,
|
||||
// businesses: widget.businessGroupedBusinesses![businessType]!));
|
||||
// }
|
||||
// headers.sort(
|
||||
// (a, b) => a.businessType!.index.compareTo(b.businessType!.index));
|
||||
// return MultiSliver(children: headers);
|
||||
// }
|
||||
// return const Text('Error with input data!');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class BusinessHeader extends StatefulWidget {
|
||||
// final JobType? jobType;
|
||||
// final BusinessType? businessType;
|
||||
// final List<Business> businesses;
|
||||
// final Set<Business>? selectedBusinesses;
|
||||
// final bool widescreen;
|
||||
// final void Function()? updateSelectedBusinessesCallback;
|
||||
//
|
||||
// const BusinessHeader({
|
||||
// super.key,
|
||||
// this.jobType,
|
||||
// this.businessType,
|
||||
// required this.businesses,
|
||||
// required this.widescreen,
|
||||
// this.updateSelectedBusinessesCallback,
|
||||
// this.selectedBusinesses,
|
||||
// });
|
||||
//
|
||||
// @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.selectedBusinesses),
|
||||
// ),
|
||||
// sliver: _getChildSliver(
|
||||
// widget.businesses, widget.widescreen, widget.selectedBusinesses),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Widget _getHeaderRow(Set<Business>? selectedBusinesses) {
|
||||
// if (selectedBusinesses != null) {
|
||||
// return Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 4.0, right: 12.0),
|
||||
// child: Icon(
|
||||
// widget.jobType != null
|
||||
// ? getIconFromJobType(widget.jobType!)
|
||||
// : getIconFromBusinessType(widget.businessType!),
|
||||
// color: Theme.of(context).colorScheme.onPrimary,
|
||||
// )),
|
||||
// Text(widget.jobType != null
|
||||
// ? getNameFromJobType(widget.jobType!)
|
||||
// : getNameFromBusinessType(widget.businessType!)),
|
||||
// ],
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(right: 12.0),
|
||||
// child: Checkbox(
|
||||
// checkColor: Theme.of(context).colorScheme.primary,
|
||||
// activeColor: Theme.of(context).colorScheme.onPrimary,
|
||||
// value: widget.selectedBusinesses!.containsAll(widget.businesses),
|
||||
// onChanged: (value) {
|
||||
// if (value!) {
|
||||
// setState(() {
|
||||
// widget.selectedBusinesses!.addAll(widget.businesses);
|
||||
// });
|
||||
// } else {
|
||||
// setState(() {
|
||||
// widget.selectedBusinesses!.removeAll(widget.businesses);
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// } else {
|
||||
// return Row(
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 4.0, right: 12.0),
|
||||
// child: Icon(
|
||||
// widget.jobType != null
|
||||
// ? getIconFromJobType(widget.jobType!)
|
||||
// : getIconFromBusinessType(widget.businessType!),
|
||||
// color: Theme.of(context).colorScheme.onPrimary,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// widget.jobType != null
|
||||
// ? getNameFromJobType(widget.jobType!)
|
||||
// : getNameFromBusinessType(widget.businessType!),
|
||||
// style: TextStyle(color: Theme.of(context).colorScheme.onPrimary),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Widget _getChildSliver(List<Business> businesses, bool widescreen,
|
||||
// Set<Business>? selectedBusinesses) {
|
||||
// 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 BusinessCard(
|
||||
// business: businesses[index],
|
||||
// selectedBusinesses: selectedBusinesses,
|
||||
// widescreen: widescreen,
|
||||
// callback: refresh,
|
||||
// jobType: widget.jobType,
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// } else {
|
||||
// return SliverList(
|
||||
// delegate: SliverChildBuilderDelegate(
|
||||
// childCount: businesses.length,
|
||||
// (BuildContext context, int index) {
|
||||
// return BusinessCard(
|
||||
// business: businesses[index],
|
||||
// selectedBusinesses: selectedBusinesses,
|
||||
// widescreen: widescreen,
|
||||
// callback: refresh,
|
||||
// jobType: widget.jobType,
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class BusinessCard extends StatefulWidget {
|
||||
// final Business business;
|
||||
// final bool widescreen;
|
||||
// final Set<Business>? selectedBusinesses;
|
||||
// final Function callback;
|
||||
// final JobType? jobType;
|
||||
// final BusinessType? businessType;
|
||||
//
|
||||
// const BusinessCard({
|
||||
// super.key,
|
||||
// required this.business,
|
||||
// required this.widescreen,
|
||||
// required this.callback,
|
||||
// this.jobType,
|
||||
// this.businessType,
|
||||
// this.selectedBusinesses,
|
||||
// });
|
||||
//
|
||||
// @override
|
||||
// State<BusinessCard> createState() => _BusinessCardState();
|
||||
// }
|
||||
//
|
||||
// class _BusinessCardState extends State<BusinessCard> {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// if (widget.widescreen) {
|
||||
// return _businessTile(widget.business, widget.selectedBusinesses,
|
||||
// widget.jobType, widget.businessType);
|
||||
// } else {
|
||||
// return _businessListItem(widget.business, widget.selectedBusinesses,
|
||||
// widget.callback, widget.jobType, widget.businessType);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Widget _businessTile(Business business, Set<Business>? selectedBusinesses,
|
||||
// JobType? jobType, BusinessType? businessType) {
|
||||
// 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: [
|
||||
// _getTileRow(business, selectedBusinesses, widget.callback),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// business.description!,
|
||||
// maxLines: selectedBusinesses != null ? 7 : 5,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// ),
|
||||
// const Spacer(),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: selectedBusinesses == null
|
||||
// ? Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
// children: [
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.link),
|
||||
// onPressed: () {
|
||||
// launchUrl(
|
||||
// Uri.parse('https://${business.website}'));
|
||||
// },
|
||||
// ),
|
||||
// if (business.locationName != '')
|
||||
// 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) &&
|
||||
// (business.contactPhone != ''))
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.phone),
|
||||
// onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertDialog(
|
||||
// backgroundColor: Theme.of(context)
|
||||
// .colorScheme
|
||||
// .surface,
|
||||
// title: Text((business.contactName ==
|
||||
// null ||
|
||||
// business.contactName == '')
|
||||
// ? 'Contact ${business.name}?'
|
||||
// : 'Contact ${business.contactName}'),
|
||||
// content: Text((business.contactName ==
|
||||
// null ||
|
||||
// business.contactName == '')
|
||||
// ? 'Would you like to call or text ${business.name}?'
|
||||
// : '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 != '')
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.email),
|
||||
// onPressed: () {
|
||||
// launchUrl(Uri.parse(
|
||||
// 'mailto:${business.contactEmail}'));
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// )
|
||||
// : null),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Widget _getTileRow(
|
||||
// Business business, Set<Business>? selectedBusinesses, Function callback) {
|
||||
// if (selectedBusinesses != null) {
|
||||
// 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 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.only(right: 24.0),
|
||||
// child: _checkbox(callback, selectedBusinesses),
|
||||
// )
|
||||
// ],
|
||||
// );
|
||||
// } 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 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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Widget _businessListItem(Business business, Set<Business>? selectedBusinesses,
|
||||
// Function callback, JobType? jobType, BusinessType? businessType) {
|
||||
// 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: 1, overflow: TextOverflow.ellipsis),
|
||||
// trailing: _getCheckbox(selectedBusinesses, callback),
|
||||
// onTap: () {
|
||||
// Navigator.of(context).push(MaterialPageRoute(
|
||||
// builder: (context) => BusinessDetail(
|
||||
// id: business.id,
|
||||
// name: business.name!,
|
||||
// )));
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Widget _checkbox(Function callback, Set<Business> selectedBusinesses) {
|
||||
// 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(Set<Business>? selectedBusinesses, Function callback) {
|
||||
// if (selectedBusinesses != null) {
|
||||
// return _checkbox(callback, selectedBusinesses);
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
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> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 450,
|
||||
height: 50,
|
||||
child: SearchBar(
|
||||
hintText: widget.searchTextHint,
|
||||
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: [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
|
||||
? BusinessSearchBar(
|
||||
setSearchCallback: widget.setSearch,
|
||||
searchTextHint: widget.searchHintText,
|
||||
filterIconButton: widget.filterIconButton,
|
||||
)
|
||||
: 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();
|
||||
}),
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
// IconButton(
|
||||
// icon: const Icon(Icons.picture_as_pdf),
|
||||
// onPressed: () async {
|
||||
// if (!_isPreviousData) {
|
||||
// ScaffoldMessenger.of(context).clearSnackBars();
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// width: 300,
|
||||
// behavior: SnackBarBehavior.floating,
|
||||
// content: Text('There is no data!'),
|
||||
// duration: Duration(seconds: 2),
|
||||
// ),
|
||||
// );
|
||||
// } else {
|
||||
// selectedDataTypesBusiness = <DataTypeBusiness>{};
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => ExportData(
|
||||
// groupedBusinesses: overviewBusinesses)));
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user