301 lines
7.3 KiB
Dart
301 lines
7.3 KiB
Dart
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;
|
|
}
|
|
}
|