Initial commit du projet Flutter
This commit is contained in:
178
lib/models/service_model.dart
Normal file
178
lib/models/service_model.dart
Normal file
@@ -0,0 +1,178 @@
|
||||
// Dans ../models/service_model.dart
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WortisService {
|
||||
final String id;
|
||||
final String name;
|
||||
final String description;
|
||||
final String secteurActivite;
|
||||
final bool status;
|
||||
final String? icon;
|
||||
final String? banner;
|
||||
final String? linkView;
|
||||
final String? typeService;
|
||||
final String? boutonList;
|
||||
final String? buttonService;
|
||||
final String? error400;
|
||||
final String? error500;
|
||||
final String? titeDescription;
|
||||
final int? rang; // ← Ajoutez cette ligne
|
||||
|
||||
WortisService({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.secteurActivite,
|
||||
required this.status,
|
||||
this.icon,
|
||||
this.banner,
|
||||
this.linkView,
|
||||
this.typeService,
|
||||
this.boutonList,
|
||||
this.buttonService,
|
||||
this.error400,
|
||||
this.error500,
|
||||
this.titeDescription,
|
||||
this.rang, // ← Ajoutez cette ligne
|
||||
});
|
||||
|
||||
factory WortisService.fromJson(Map<String, dynamic> json) {
|
||||
return WortisService(
|
||||
id: json['_id'] ?? '',
|
||||
name: json['name'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
secteurActivite: json['SecteurActivite'] ?? '',
|
||||
status: json['status'] ?? false,
|
||||
icon: json['icon'],
|
||||
banner: json['banner'],
|
||||
linkView: json['link_view'],
|
||||
typeService: json['Type_Service'],
|
||||
boutonList: json['bouton_list'],
|
||||
buttonService: json['button_service'],
|
||||
error400: json['error_400'],
|
||||
error500: json['error_500'],
|
||||
titeDescription: json['tite_description'],
|
||||
rang: json['rang'] as int?, // ← Ajoutez cette ligne
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'_id': id,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'SecteurActivite': secteurActivite,
|
||||
'status': status,
|
||||
'icon': icon,
|
||||
'banner': banner,
|
||||
'link_view': linkView,
|
||||
'Type_Service': typeService,
|
||||
'bouton_list': boutonList,
|
||||
'button_service': buttonService,
|
||||
'error_400': error400,
|
||||
'error_500': error500,
|
||||
'tite_description': titeDescription,
|
||||
'rang': rang, // ← Ajoutez cette ligne
|
||||
};
|
||||
}
|
||||
|
||||
// Getter pour l'icône Flutter (vous pouvez garder votre logique existante)
|
||||
IconData get flutterIcon {
|
||||
switch (icon?.toLowerCase()) {
|
||||
case 'movie':
|
||||
return Icons.movie;
|
||||
case 'car':
|
||||
return Icons.directions_car;
|
||||
case 'shopping':
|
||||
return Icons.shopping_cart;
|
||||
case 'food':
|
||||
return Icons.restaurant;
|
||||
case 'hotel':
|
||||
return Icons.hotel;
|
||||
case 'transport':
|
||||
return Icons.directions_bus;
|
||||
case 'health':
|
||||
return Icons.local_hospital;
|
||||
case 'education':
|
||||
return Icons.school;
|
||||
case 'finance':
|
||||
return Icons.account_balance;
|
||||
default:
|
||||
return Icons.miscellaneous_services;
|
||||
}
|
||||
}
|
||||
|
||||
// Getter pour la couleur du secteur (vous pouvez garder votre logique existante)
|
||||
Color get sectorColor {
|
||||
switch (secteurActivite.toLowerCase()) {
|
||||
case 'billetterie':
|
||||
return Color(0xFF6B46C1);
|
||||
case 'transport':
|
||||
return Color(0xFF059669);
|
||||
case 'restauration':
|
||||
return Color(0xFFDC2626);
|
||||
case 'hébergement':
|
||||
return Color(0xFF2563EB);
|
||||
case 'finance':
|
||||
return Color(0xFF7C2D12);
|
||||
case 'santé':
|
||||
return Color(0xFF0891B2);
|
||||
case 'éducation':
|
||||
return Color(0xFF7C3AED);
|
||||
default:
|
||||
return Color(0xFF6B7280);
|
||||
}
|
||||
}
|
||||
|
||||
// Méthode copyWith pour créer une copie avec des modifications
|
||||
WortisService copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
String? description,
|
||||
String? secteurActivite,
|
||||
bool? status,
|
||||
String? icon,
|
||||
String? banner,
|
||||
String? linkView,
|
||||
String? typeService,
|
||||
String? boutonList,
|
||||
String? buttonService,
|
||||
String? error400,
|
||||
String? error500,
|
||||
String? titeDescription,
|
||||
int? rang,
|
||||
}) {
|
||||
return WortisService(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
description: description ?? this.description,
|
||||
secteurActivite: secteurActivite ?? this.secteurActivite,
|
||||
status: status ?? this.status,
|
||||
icon: icon ?? this.icon,
|
||||
banner: banner ?? this.banner,
|
||||
linkView: linkView ?? this.linkView,
|
||||
typeService: typeService ?? this.typeService,
|
||||
boutonList: boutonList ?? this.boutonList,
|
||||
buttonService: buttonService ?? this.buttonService,
|
||||
error400: error400 ?? this.error400,
|
||||
error500: error500 ?? this.error500,
|
||||
titeDescription: titeDescription ?? this.titeDescription,
|
||||
rang: rang ?? this.rang,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WortisService(id: $id, name: $name, secteur: $secteurActivite, status: $status, rang: $rang)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is WortisService && other.id == id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
}
|
||||
Reference in New Issue
Block a user