feat: add relay actived history
This commit is contained in:
parent
6350a22b00
commit
305443f291
|
|
@ -1,15 +1,15 @@
|
|||
class RelayResponse {
|
||||
bool? success;
|
||||
List<Data>? data;
|
||||
List<Relay>? data;
|
||||
|
||||
RelayResponse({this.success, this.data});
|
||||
|
||||
RelayResponse.fromJson(Map<String, dynamic> json) {
|
||||
success = json['success'];
|
||||
if (json['data'] != null) {
|
||||
data = <Data>[];
|
||||
data = <Relay>[];
|
||||
json['data'].forEach((v) {
|
||||
data!.add(Data.fromJson(v));
|
||||
data!.add(Relay.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ class RelayResponse {
|
|||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
class Relay {
|
||||
int? id;
|
||||
int? number;
|
||||
String? enabledAt;
|
||||
|
|
@ -32,7 +32,7 @@ class Data {
|
|||
bool? currentStatus;
|
||||
String? createdAt;
|
||||
|
||||
Data(
|
||||
Relay(
|
||||
{this.id,
|
||||
this.number,
|
||||
this.enabledAt,
|
||||
|
|
@ -40,7 +40,7 @@ class Data {
|
|||
this.currentStatus,
|
||||
this.createdAt});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
Relay.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
number = json['number'];
|
||||
enabledAt = json['enabled_at'];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
import 'package:agrilink_vocpro/core/constant/app_theme.dart';
|
||||
import 'package:agrilink_vocpro/core/extension/extention.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
import '../../../core/constant/app_color.dart';
|
||||
|
||||
class RelayStatusHistoryWidget extends StatelessWidget {
|
||||
const RelayStatusHistoryWidget({
|
||||
super.key,
|
||||
required this.disabledAt,
|
||||
required this.enabledAt,
|
||||
required this.name,
|
||||
required this.imageUrl,
|
||||
});
|
||||
|
||||
final String? disabledAt;
|
||||
final String? enabledAt;
|
||||
final String name;
|
||||
final String imageUrl;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 26.r,
|
||||
backgroundColor: AppColor.ternary,
|
||||
child: Image.asset(
|
||||
imageUrl,
|
||||
width: 24.r,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
name,
|
||||
style: AppTheme.labelMedium,
|
||||
),
|
||||
subtitle: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.greenAccent,
|
||||
radius: 4.r,
|
||||
),
|
||||
Text(
|
||||
' Aktif ${timeAgo(enabledAt)}',
|
||||
style: AppTheme.labelSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.grey.shade300,
|
||||
radius: 4.r,
|
||||
),
|
||||
Text(
|
||||
' Nonaktif ${timeAgo(disabledAt)}',
|
||||
style: AppTheme.labelSmall,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user