2023-02-26 14:10:06 +01:00
|
|
|
import 'package:smoke_cess_app/services/json_service.dart';
|
2023-02-19 17:31:46 +01:00
|
|
|
|
2023-02-17 13:47:52 +01:00
|
|
|
class Settings {
|
2023-02-27 11:39:42 +01:00
|
|
|
final int group;
|
2023-02-19 17:31:46 +01:00
|
|
|
final List<String>? relapseCategories;
|
2023-02-27 11:19:56 +01:00
|
|
|
final QueryConfig? moodQuery;
|
|
|
|
final QueryConfig? sleepQuery;
|
2023-02-19 17:31:46 +01:00
|
|
|
final TimeConfig? chessTime;
|
2023-03-05 20:43:02 +01:00
|
|
|
final DateTime startedAt;
|
2023-02-17 13:47:52 +01:00
|
|
|
|
2023-02-19 17:31:46 +01:00
|
|
|
Settings(this.group, this.relapseCategories, this.moodQuery, this.sleepQuery,
|
2023-03-05 20:43:02 +01:00
|
|
|
this.chessTime, this.startedAt);
|
2023-02-17 13:47:52 +01:00
|
|
|
|
|
|
|
Settings.fromJson(Map<String, dynamic> json)
|
2023-02-20 19:50:09 +01:00
|
|
|
: group = json['group'] as int,
|
2023-02-19 17:31:46 +01:00
|
|
|
relapseCategories = jsonPropertyAsList(json['relapse_categories']),
|
|
|
|
moodQuery = QueryConfig.fromJson(json['mood_query']),
|
|
|
|
sleepQuery = QueryConfig.fromJson(json['sleep_query']),
|
2023-02-19 17:44:20 +01:00
|
|
|
chessTime = json['chess_time'] != null
|
|
|
|
? TimeConfig.fromJson(json['chess_time'])
|
2023-03-05 20:43:02 +01:00
|
|
|
: null,
|
|
|
|
startedAt = DateTime.parse(json['startedAt']);
|
2023-02-19 17:31:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class QueryConfig {
|
2023-02-27 11:19:56 +01:00
|
|
|
final int? hours;
|
|
|
|
final int? minutes;
|
2023-02-19 17:31:46 +01:00
|
|
|
final List<String>? days;
|
|
|
|
|
|
|
|
QueryConfig(this.hours, this.minutes, this.days);
|
|
|
|
|
|
|
|
QueryConfig.fromJson(Map<String, dynamic> json)
|
|
|
|
: hours = json['hours'] as int,
|
|
|
|
minutes = json['minutes'] as int,
|
|
|
|
days = jsonPropertyAsList(json['days']);
|
|
|
|
}
|
|
|
|
|
|
|
|
class TimeConfig {
|
2023-02-27 11:19:56 +01:00
|
|
|
final int? hours;
|
|
|
|
final int? minutes;
|
2023-02-19 17:31:46 +01:00
|
|
|
|
|
|
|
TimeConfig(this.hours, this.minutes);
|
|
|
|
|
|
|
|
TimeConfig.fromJson(Map<String, dynamic> json)
|
|
|
|
: hours = json['hours'] as int,
|
|
|
|
minutes = json['minutes'] as int;
|
2023-02-17 13:47:52 +01:00
|
|
|
}
|