172 lines
4.3 KiB
Dart
172 lines
4.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class AppIcons {
|
|
// Icon API sederhana menggunakan Flutter Icons
|
|
static const IconData apiIcon = Icons.api;
|
|
static const IconData fireIcon = Icons.local_fire_department;
|
|
static const IconData sensorIcon = Icons.sensors;
|
|
static const IconData dashboardIcon = Icons.dashboard;
|
|
static const IconData settingsIcon = Icons.settings;
|
|
static const IconData networkIcon = Icons.wifi;
|
|
static const IconData databaseIcon = Icons.storage;
|
|
|
|
// Custom API Icon Widget
|
|
static Widget buildApiIcon({
|
|
double size = 24,
|
|
Color? color,
|
|
bool showBadge = false,
|
|
}) {
|
|
return Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Icon(Icons.api, size: size, color: color ?? Colors.blue),
|
|
if (showBadge)
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
child: Container(
|
|
width: size * 0.3,
|
|
height: size * 0.3,
|
|
decoration: const BoxDecoration(
|
|
color: Colors.green,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// Custom Fire Detection Icon
|
|
static Widget buildFireDetectionIcon({
|
|
double size = 24,
|
|
Color? color,
|
|
bool isActive = false,
|
|
}) {
|
|
return Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.local_fire_department,
|
|
size: size,
|
|
color: isActive ? Colors.red : (color ?? Colors.grey),
|
|
),
|
|
if (isActive)
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
child: Container(
|
|
width: size * 0.25,
|
|
height: size * 0.25,
|
|
decoration: const BoxDecoration(
|
|
color: Colors.red,
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(Icons.warning, color: Colors.white, size: 8),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// Custom Sensor Icon
|
|
static Widget buildSensorIcon({
|
|
double size = 24,
|
|
Color? color,
|
|
bool isOnline = true,
|
|
}) {
|
|
return Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Icon(Icons.sensors, size: size, color: color ?? Colors.blue),
|
|
Positioned(
|
|
bottom: 0,
|
|
right: 0,
|
|
child: Container(
|
|
width: size * 0.25,
|
|
height: size * 0.25,
|
|
decoration: BoxDecoration(
|
|
color: isOnline ? Colors.green : Colors.red,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// Logo/Brand Icon untuk App
|
|
static Widget buildAppLogo({
|
|
double size = 48,
|
|
Color? primaryColor,
|
|
Color? secondaryColor,
|
|
}) {
|
|
return Container(
|
|
width: size,
|
|
height: size,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
primaryColor ?? Colors.blue,
|
|
secondaryColor ?? Colors.blueAccent,
|
|
],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: (primaryColor ?? Colors.blue).withOpacity(0.3),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 4),
|
|
),
|
|
],
|
|
),
|
|
child: Icon(Icons.api, size: size * 0.6, color: Colors.white),
|
|
);
|
|
}
|
|
|
|
// Icon untuk berbagai status
|
|
static IconData getStatusIcon(String status) {
|
|
switch (status.toLowerCase()) {
|
|
case 'online':
|
|
case 'active':
|
|
return Icons.check_circle;
|
|
case 'offline':
|
|
case 'inactive':
|
|
return Icons.offline_bolt;
|
|
case 'warning':
|
|
return Icons.warning;
|
|
case 'error':
|
|
case 'danger':
|
|
return Icons.error;
|
|
case 'loading':
|
|
return Icons.refresh;
|
|
default:
|
|
return Icons.help;
|
|
}
|
|
}
|
|
|
|
// Color untuk berbagai status
|
|
static Color getStatusColor(String status) {
|
|
switch (status.toLowerCase()) {
|
|
case 'online':
|
|
case 'active':
|
|
case 'normal':
|
|
return Colors.green;
|
|
case 'offline':
|
|
case 'inactive':
|
|
return Colors.grey;
|
|
case 'warning':
|
|
return Colors.orange;
|
|
case 'error':
|
|
case 'danger':
|
|
return Colors.red;
|
|
case 'loading':
|
|
return Colors.blue;
|
|
default:
|
|
return Colors.grey;
|
|
}
|
|
}
|
|
}
|