76 lines
2.1 KiB
Dart
76 lines
2.1 KiB
Dart
import 'package:digiplug/core/navigation/navigator.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
// Enum untuk mendefinisikan semua jenis perangkat yang mungkin ada
|
|
enum DeviceType {
|
|
ac,
|
|
smartTv,
|
|
cctv,
|
|
refridgerator,
|
|
microwave,
|
|
light,
|
|
plug,
|
|
}
|
|
|
|
// Extension untuk menambahkan fungsionalitas tambahan pada enum DeviceType
|
|
extension DeviceTypeExtension on DeviceType {
|
|
// Mengembalikan nama yang mudah dibaca untuk setiap tipe perangkat
|
|
String get name {
|
|
switch (this) {
|
|
case DeviceType.ac:
|
|
return 'AC';
|
|
case DeviceType.smartTv:
|
|
return 'Smart TV';
|
|
case DeviceType.cctv:
|
|
return 'CCTV';
|
|
case DeviceType.refridgerator:
|
|
return 'Kulkas';
|
|
case DeviceType.microwave:
|
|
return 'Microwave';
|
|
case DeviceType.light:
|
|
return 'Lampu';
|
|
case DeviceType.plug:
|
|
return 'DigiPlug';
|
|
}
|
|
}
|
|
|
|
// Mengembalikan path aset ikon atau objek IconData untuk setiap tipe perangkat
|
|
dynamic get icon {
|
|
switch (this) {
|
|
case DeviceType.ac:
|
|
return 'assets/icons/ac.png';
|
|
case DeviceType.smartTv:
|
|
return 'assets/icons/tv.png';
|
|
case DeviceType.cctv:
|
|
return 'assets/icons/cctv.png';
|
|
case DeviceType.refridgerator:
|
|
return 'assets/icons/fridge.png';
|
|
case DeviceType.microwave:
|
|
return 'assets/icons/oven.png';
|
|
case DeviceType.light:
|
|
return 'assets/icons/light.png';
|
|
case DeviceType.plug:
|
|
// Menggunakan SVG untuk fleksibilitas
|
|
return 'assets/icons/plug.svg';
|
|
}
|
|
}
|
|
|
|
// Mengembalikan nama rute yang sesuai untuk navigasi saat kartu perangkat di-tap
|
|
String get routeName {
|
|
switch (this) {
|
|
case DeviceType.ac:
|
|
return acRoute;
|
|
case DeviceType.smartTv:
|
|
return smartTvRoute;
|
|
case DeviceType.light:
|
|
return lightRoute;
|
|
case DeviceType.plug:
|
|
return digiPlugDetailRoute;
|
|
// Untuk perangkat yang tidak memiliki halaman detail khusus,
|
|
// kita bisa arahkan ke rute yang sama atau rute placeholder.
|
|
default:
|
|
return digiPlugDetailRoute;
|
|
}
|
|
}
|
|
}
|