feat: honestly forgot
This commit is contained in:
parent
48bcf0b1f8
commit
da953ba651
19 changed files with 1097 additions and 244 deletions
46
<
Normal file
46
<
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import 'package:provider/provider.dart';
|
||||
|
||||
enum State { pending, ongoing, ended }
|
||||
|
||||
class Bal {
|
||||
Bal({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.state,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
});
|
||||
|
||||
int id;
|
||||
String name;
|
||||
State state;
|
||||
DateTime startTime;
|
||||
DateTime endTime;
|
||||
|
||||
factory Bal.fromJSON(Map<String, dynamic> json) => Bal(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
state: switch (json["state"]) {
|
||||
"Pending" => State.pending,
|
||||
"Ongoing" => State.ongoing,
|
||||
_ => State.ended,
|
||||
},
|
||||
startTime: DateTime.fromMillisecondsSinceEpoch(
|
||||
json["start_timestamp"] * 1000,
|
||||
isUtc: true,
|
||||
),
|
||||
endTime: DateTime.fromMillisecondsSinceEpoch(
|
||||
json["end_timestamp"] * 1000,
|
||||
isUtc: true,
|
||||
),
|
||||
);
|
||||
|
||||
int compareTo(Bal other) {
|
||||
if (ended == other.ended) {
|
||||
return 0;
|
||||
} else if (ended) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
Reference in a new issue