151 lines
4.1 KiB
Dart
151 lines
4.1 KiB
Dart
// lib/app/modules/home_patient/controllers/home_patient_controller.dart
|
|
import 'package:get/get.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../../../models/chart_data_point.dart'; // Import model yang terpisah
|
|
|
|
class InfusData {
|
|
final String dropsPerMinute;
|
|
final String room;
|
|
final String deviceId;
|
|
final String updateTime;
|
|
|
|
InfusData({
|
|
required this.dropsPerMinute,
|
|
required this.room,
|
|
required this.deviceId,
|
|
required this.updateTime,
|
|
});
|
|
}
|
|
|
|
class NotificationData {
|
|
final String title;
|
|
final String message;
|
|
final String room;
|
|
final String deviceId;
|
|
final String timeAgo;
|
|
|
|
NotificationData({
|
|
required this.title,
|
|
required this.message,
|
|
required this.room,
|
|
required this.deviceId,
|
|
required this.timeAgo,
|
|
});
|
|
}
|
|
|
|
class HomePatientController extends GetxController {
|
|
// Patient info
|
|
final patientName = 'Mrs. Shinta'.obs;
|
|
|
|
// Banner carousel
|
|
final currentCarouselIndex = 0.obs;
|
|
final bannerImages = [
|
|
'assets/images/banner-slider3.png',
|
|
'assets/images/banner-slider4.png',
|
|
];
|
|
|
|
// Current monitoring data
|
|
final currentInfusData = InfusData(
|
|
dropsPerMinute: '30 tetes per menit',
|
|
room: 'MAWAR 002',
|
|
deviceId: 'SI001',
|
|
updateTime: '5min ago',
|
|
).obs;
|
|
|
|
// Chart data dengan 10 data points
|
|
final chartDataPoints = <ChartDataPoint>[
|
|
ChartDataPoint(hour: 8, dropsPerMinute: 25),
|
|
ChartDataPoint(hour: 9, dropsPerMinute: 28),
|
|
ChartDataPoint(hour: 10, dropsPerMinute: 30),
|
|
ChartDataPoint(hour: 11, dropsPerMinute: 32),
|
|
ChartDataPoint(hour: 12, dropsPerMinute: 35),
|
|
ChartDataPoint(hour: 13, dropsPerMinute: 33),
|
|
ChartDataPoint(hour: 14, dropsPerMinute: 30),
|
|
ChartDataPoint(hour: 15, dropsPerMinute: 28),
|
|
ChartDataPoint(hour: 16, dropsPerMinute: 26),
|
|
ChartDataPoint(hour: 17, dropsPerMinute: 30),
|
|
].obs;
|
|
|
|
// Notifications list
|
|
final notificationsList = <NotificationData>[
|
|
NotificationData(
|
|
title: 'Peringatan!!',
|
|
message: 'Aliran infus telah terhenti. Mohon hubungi perawat segera.',
|
|
room: 'MAWAR 002',
|
|
deviceId: 'SI001',
|
|
timeAgo: '5min ago',
|
|
),
|
|
NotificationData(
|
|
title: 'Peringatan!!',
|
|
message: 'Aliran infus telah terhenti. Mohon hubungi perawat segera.',
|
|
room: 'MELATI 001',
|
|
deviceId: 'SI002',
|
|
timeAgo: '10min ago',
|
|
),
|
|
].obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
super.onClose();
|
|
}
|
|
|
|
void updateCarouselIndex(int index) {
|
|
currentCarouselIndex.value = index;
|
|
}
|
|
|
|
// Show call dialog
|
|
void showCallDialog(BuildContext context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(15),
|
|
),
|
|
title: const Text(
|
|
'Hubungi Perawat',
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
content: const Text('Apakah Anda ingin menghubungi perawat?'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: Text('Batal', style: TextStyle(color: Colors.grey[600])),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
// Implement call functionality
|
|
Get.snackbar(
|
|
'Menghubungi',
|
|
'Sedang menghubungi perawat...',
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
backgroundColor: Colors.blue,
|
|
colorText: Colors.white,
|
|
);
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFF2196F3),
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
),
|
|
child: const Text('Hubungi'),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
} |